1#ifndef CPARK_MERGE_RDD_H
2#define CPARK_MERGE_RDD_H
26template <concepts::Rdd R>
35 using difference_type = std::ptrdiff_t;
37 using iterator_category = std::forward_iterator_tag;
38 using value_type = utils::RddElementType<R>;
39 using OriginalIterator = std::ranges::iterator_t<std::ranges::range_value_t<R>>;
40 using OriginalSentinel = std::ranges::sentinel_t<std::ranges::range_value_t<R>>;
44 Iterator(std::vector<OriginalIterator>
begins, std::vector<OriginalIterator>
ends,
bool isEnd =
false)
45 : begins_(std::move(
begins)), ends_(std::move(
ends)), isEnd_(isEnd) {
48 current_ = begins_.size() > 0 ? begins_[row_] : OriginalIterator();
51 row_ = ends_.size() > 0 ? ends_.size() - 1 : 0;
52 current_ = ends_.size() > 0 ? ends_[row_] : OriginalIterator();
65 while (current_ == ends_[row_] && row_ + 1 < begins_.size()) {
67 current_ = begins_[row_];
129 return current_ <
other.current_;
134 return current_ >
other.current_;
139 return current_ <=
other.current_;
144 return current_ >=
other.current_;
149 return current_ -
other.current_;
153 std::vector<OriginalIterator> begins_;
154 std::vector<OriginalIterator> ends_;
155 OriginalIterator current_;
166 "Instance of MergeRdd does not satisfy Rdd concept.");
168 using OriginalIterator = std::ranges::iterator_t<std::ranges::range_value_t<R>>;
177 splits_.emplace_back(
178 std::ranges::subrange{
195 constexpr auto beginImpl()
const {
return std::ranges::begin(splits_); }
197 constexpr auto endImpl()
const {
return std::ranges::end(splits_); }
200 std::vector<ViewSplit<std::ranges::subrange<Iterator>>> splits_{};
208 explicit Merge() =
default;
210 template <concepts::Rdd R>
211 auto operator()(
const R&
r)
const {
219template <concepts::Rdd R>
Definition base_rdd.h:522
Definition merge_rdd.h:206
Definition merge_rdd.h:33
value_type * operator->() const
Definition merge_rdd.h:60
Iterator & operator++()
Definition merge_rdd.h:63
bool operator<(const Iterator &other) const
Definition merge_rdd.h:128
difference_type operator-(const Iterator &other) const
Definition merge_rdd.h:148
bool operator==(const Iterator &other) const
Definition merge_rdd.h:122
bool operator!=(const Iterator &other) const
Definition merge_rdd.h:125
bool operator>=(const Iterator &other) const
Definition merge_rdd.h:143
Iterator & operator-=(difference_type n)
Definition merge_rdd.h:98
bool operator<=(const Iterator &other) const
Definition merge_rdd.h:138
Iterator operator++(int)
Definition merge_rdd.h:73
Iterator & operator+=(difference_type n)
Definition merge_rdd.h:82
value_type operator*() const
Definition merge_rdd.h:57
Iterator operator-(difference_type n) const
Definition merge_rdd.h:110
Iterator operator+(difference_type n) const
Definition merge_rdd.h:103
value_type & operator[](difference_type n) const
Definition merge_rdd.h:117
bool operator>(const Iterator &other) const
Definition merge_rdd.h:133
Definition merge_rdd.h:27
constexpr MergeRdd(const R &prev)
Definition merge_rdd.h:164
auto operator|(const R &r, const Collect &collect)
Definition collect.h:48