16 #ifndef STXXL_CONTAINERS_PQ_MERGERS_HEADER
17 #define STXXL_CONTAINERS_PQ_MERGERS_HEADER
29 namespace priority_queue_local {
40 template <
class InputIterator,
class OutputIterator,
41 class CompareType,
typename SizeType>
43 InputIterator& source0,
44 InputIterator& source1,
45 OutputIterator target,
49 OutputIterator done = target + length;
51 while (target != done)
53 if (cmp(*source0, *source1))
73 template <
class InputIterator,
class OutputIterator,
74 class CompareType,
typename SizeType>
76 InputIterator& source0,
77 InputIterator& source1,
78 InputIterator& source2,
79 OutputIterator target,
83 OutputIterator done = target + length;
85 if (cmp(*source1, *source0)) {
86 if (cmp(*source2, *source1)) {
90 if (cmp(*source0, *source2)) {
98 if (cmp(*source2, *source1)) {
99 if (cmp(*source2, *source0)) {
110 #define Merge3Case(a, b, c) \
112 if (target == done) \
114 *target = *source ## a; \
117 if (cmp(*source ## b, *source ## a)) \
118 goto s ## a ## b ## c; \
119 if (cmp(*source ## c, *source ## a)) \
120 goto s ## b ## a ## c; \
121 goto s ## b ## c ## a;
141 template <
class InputIterator,
class OutputIterator,
142 class CompareType,
typename SizeType>
144 InputIterator& source0,
145 InputIterator& source1,
146 InputIterator& source2,
147 InputIterator& source3,
148 OutputIterator target, SizeType length, CompareType& cmp)
150 OutputIterator done = target + length;
152 #define StartMerge4(a, b, c, d) \
153 if ((!cmp(*source ## a, *source ## b)) && \
154 (!cmp(*source ## b, *source ## c)) && \
155 (!cmp(*source ## c, *source ## d))) \
156 goto s ## a ## b ## c ## d;
193 #define Merge4Case(a, b, c, d) \
194 s ## a ## b ## c ## d : \
195 if (target == done) \
197 *target = *source ## a; \
200 if (cmp(*source ## c, *source ## a)) \
202 if (cmp(*source ## b, *source ## a)) \
203 goto s ## a ## b ## c ## d; \
205 goto s ## b ## a ## c ## d; \
209 if (cmp(*source ## d, *source ## a)) \
210 goto s ## b ## c ## a ## d; \
212 goto s ## b ## c ## d ## a; \
255 #endif // !STXXL_CONTAINERS_PQ_MERGERS_HEADER
#define StartMerge4(a, b, c, d)
void merge3_iterator(InputIterator &source0, InputIterator &source1, InputIterator &source2, OutputIterator target, SizeType length, CompareType &cmp)
#define STXXL_BEGIN_NAMESPACE
#define Merge4Case(a, b, c, d)
void merge_iterator(InputIterator &source0, InputIterator &source1, OutputIterator target, SizeType length, CompareType &cmp)
#define Merge3Case(a, b, c)
#define STXXL_END_NAMESPACE
void merge4_iterator(InputIterator &source0, InputIterator &source1, InputIterator &source2, InputIterator &source3, OutputIterator target, SizeType length, CompareType &cmp)