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 inline merger(pred_t pred, specific_store_t store,
46 inline bool can_pull() {
50 inline store_type pull() {
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);
92 inline static memory_size_type memory_usage(memory_size_type fanout) {
107 typedef std::pair<store_type, size_t> item_type;
108 typedef item_type first_argument_type;
109 typedef item_type second_argument_type;
110 typedef bool result_type;
117 inline bool operator()(
const item_type & lhs,
const item_type & rhs) {
118 return pred(lhs.first, rhs.first);
129 stream_size_type runLength;
130 specific_store_t m_store;
135 #endif // __TPIE_PIPELINING_MERGER_H__
Defines the tp_assert macro.
A generic array with a fixed size.
Standard binary internal heap.
Compressed stream public API.
Simple heap based priority queue implementation.
Class storring a reference to a memory bucket.
void resize(size_t size, const T &elm)
Change the size of the array.
#define tp_assert(condition, message)