20 #ifndef __TPIE_PIPELINING_MERGER_H__
21 #define __TPIE_PIPELINING_MERGER_H__
25 #include <tpie/file_stream.h>
27 #include <tpie/pipelining/store.h>
30 template <
typename specific_store_t,
typename pred_t>
33 typedef typename specific_store_t::store_type store_type;
34 typedef typename specific_store_t::element_type element_type;
38 merger(pred_t pred, specific_store_t store,
51 tp_assert(can_pull(),
"pull() while !can_pull()");
52 store_type el = std::move(pq.top().first);
53 size_t i = pq.top().second;
54 if (in[i].can_read() && itemsRead[i] < runLength) {
56 std::make_pair(m_store.element_to_store(in[i].read()), i));
79 this->runLength = runLength;
80 tp_assert(pq.empty(),
"Reset before we are done");
83 for (
size_t i = 0; i < in.size(); ++i) {
86 m_store.element_to_store(in[i].read()), i));
89 itemsRead.
resize(in.size(), 1);
107 static constexpr memory_size_type memory_usage(memory_size_type fanout) noexcept {
108 return memory_usage()(fanout);
113 typedef std::pair<store_type, size_t> item_type;
114 typedef item_type first_argument_type;
115 typedef item_type second_argument_type;
116 typedef bool result_type;
123 inline bool operator()(
const item_type & lhs,
const item_type & rhs) {
124 return pred(lhs.first, rhs.first);
135 stream_size_type runLength;
136 specific_store_t m_store;
141 #endif // __TPIE_PIPELINING_MERGER_H__