14 #ifndef STXXL_RUN_CURSOR_HEADER
15 #define STXXL_RUN_CURSOR_HEADER
18 #include <stxxl/bits/common/types.h>
21 __STXXL_BEGIN_NAMESPACE
23 template <
typename block_type>
29 run_cursor() : pos(0), buffer(NULL) { }
31 inline typename block_type::const_reference current()
const
33 return (*buffer)[pos];
35 inline void operator ++ ()
41 #ifdef STXXL_SORT_SINGLE_PREFETCHER
43 template <
typename must_be_
void =
void>
44 struct have_prefetcher
46 static void * untyped_prefetcher;
51 template <
typename block_type,
52 typename prefetcher_type_>
53 struct run_cursor2 :
public run_cursor<block_type>
54 #ifdef STXXL_SORT_SINGLE_PREFETCHER
55 ,
public have_prefetcher<>
58 typedef prefetcher_type_ prefetcher_type;
59 typedef run_cursor2<block_type, prefetcher_type> _Self;
60 typedef typename block_type::value_type value_type;
62 using run_cursor<block_type>::pos;
63 using run_cursor<block_type>::buffer;
65 #ifdef STXXL_SORT_SINGLE_PREFETCHER
66 static prefetcher_type *
const prefetcher()
68 return reinterpret_cast<prefetcher_type *
>(untyped_prefetcher);
70 static void set_prefetcher(prefetcher_type * pfptr)
72 untyped_prefetcher = pfptr;
76 prefetcher_type * prefetcher_;
77 prefetcher_type * & prefetcher()
83 run_cursor2(prefetcher_type * p) : prefetcher_(p) { }
86 inline bool empty()
const
88 return (pos >= block_type::size);
90 inline void operator ++ ();
91 inline void make_inf()
93 pos = block_type::size;
97 #ifdef STXXL_SORT_SINGLE_PREFETCHER
98 template <
typename must_be_
void>
99 void * have_prefetcher<must_be_void>::untyped_prefetcher = NULL;
102 template <
typename block_type,
103 typename prefetcher_type>
104 void run_cursor2<block_type, prefetcher_type>::operator ++ ()
108 if (UNLIKELY(pos >= block_type::size))
110 if (prefetcher()->block_consumed(buffer))
117 template <
typename block_type>
118 struct run_cursor_cmp
120 typedef run_cursor<block_type> cursor_type;
122 inline bool operator () (
const cursor_type & a,
const cursor_type & b)
124 return !((*a.buffer)[a.pos] < (*b.buffer)[b.pos]);
129 __STXXL_END_NAMESPACE
132 #endif // !STXXL_RUN_CURSOR_HEADER