12 #ifndef THRILL_CORE_MULTIWAY_MERGE_HEADER 13 #define THRILL_CORE_MULTIWAY_MERGE_HEADER 27 typename ReaderIterator,
33 using Reader =
typename std::iterator_traits<ReaderIterator>::value_type;
38 const Comparator& comp)
40 num_inputs_(static_cast<unsigned>(readers_end - readers_begin)),
54 lt_.insert_start(
nullptr, t,
true);
69 unsigned top =
lt_.min_source();
70 ValueType res = std::move(
current_[top].second);
75 lt_.delete_min_insert(&
current_[top].second,
false);
79 lt_.delete_min_insert(
nullptr,
true);
84 return std::make_pair(res, top);
90 unsigned top =
lt_.min_source();
91 ValueType res = std::move(
current_[top].second);
96 lt_.delete_min_insert(&
current_[top].second,
false);
100 lt_.delete_min_insert(
nullptr,
true);
130 template <
typename ValueType,
typename ReaderIterator,
131 typename Comparator = std::less<ValueType> >
133 ReaderIterator seqs_begin, ReaderIterator seqs_end,
134 const Comparator& comp = Comparator()) {
136 assert(seqs_end - seqs_begin >= 1);
138 seqs_begin, seqs_end, comp);
156 template <
typename ValueType,
typename ReaderIterator,
157 typename Comparator = std::less<ValueType> >
159 ReaderIterator seqs_begin, ReaderIterator seqs_end,
160 const Comparator& comp = Comparator()) {
162 assert(seqs_end - seqs_begin >= 1);
164 seqs_begin, seqs_end, comp);
170 #endif // !THRILL_CORE_MULTIWAY_MERGE_HEADER MultiwayMergeTree(ReaderIterator readers_begin, ReaderIterator readers_end, const Comparator &comp)
auto make_stable_multiway_merge_tree(ReaderIterator seqs_begin, ReaderIterator seqs_end, const Comparator &comp=Comparator())
Sequential multi-way merging switch for a file writer as output.
std::pair< ValueType, unsigned > NextWithSource()
auto make_multiway_merge_tree(ReaderIterator seqs_begin, ReaderIterator seqs_end, const Comparator &comp=Comparator())
Sequential multi-way merging switch for a file writer as output.
tlx::LoserTree< Stable, ValueType, Comparator > LoserTreeType
std::vector< std::pair< bool, ValueType > > current_
current values in each input (exist flag, value)
typename std::iterator_traits< ReaderIterator >::value_type Reader