15 #ifndef STXXL_ALGO_SCAN_HEADER
16 #define STXXL_ALGO_SCAN_HEADER
50 template <
typename ExtIterator,
typename UnaryFunction>
51 UnaryFunction
for_each(ExtIterator begin, ExtIterator end, UnaryFunction functor,
int_type nbuffers = 0)
61 nbuffers = 2 * config::get_instance()->disks_number();
64 buf_istream_type in(begin.bid(), end.bid() + ((end.block_offset()) ? 1 : 0), nbuffers);
66 ExtIterator cur = begin - begin.block_offset();
69 for ( ; cur != begin; ++cur)
71 typename ExtIterator::value_type tmp;
76 for ( ; cur != end; ++cur)
78 typename ExtIterator::value_type tmp;
84 if (end.block_offset())
86 ExtIterator _last_block_end = end - end.block_offset() + ExtIterator::block_type::size;
87 for ( ; cur != _last_block_end; ++cur)
89 typename ExtIterator::value_type tmp;
120 template <
typename ExtIterator,
typename UnaryFunction>
121 UnaryFunction
for_each_m(ExtIterator begin, ExtIterator end, UnaryFunction functor,
int_type nbuffers = 0)
132 nbuffers = 2 * config::get_instance()->disks_number();
135 buf_istream_type in(begin.bid(), end.bid() + ((end.block_offset()) ? 1 : 0), nbuffers / 2);
137 buf_ostream_type out(begin.bid(), nbuffers / 2);
141 ExtIterator cur = begin - begin.block_offset();
144 for ( ; cur != begin; ++cur)
146 typename ExtIterator::value_type tmp;
152 for ( ; cur != end; ++cur)
154 typename ExtIterator::value_type tmp;
161 if (end.block_offset())
163 ExtIterator _last_block_end = end - end.block_offset() + ExtIterator::block_type::size;
164 for ( ; cur != _last_block_end; ++cur)
166 typename ExtIterator::value_type tmp;
193 template <
typename ExtIterator,
typename Generator>
194 void generate(ExtIterator begin, ExtIterator end, Generator generator,
int_type nbuffers = 0)
196 typedef typename ExtIterator::block_type block_type;
200 while (begin.block_offset())
206 *begin = generator();
213 nbuffers = 2 * config::get_instance()->disks_number();
216 buf_ostream_type outstream(begin.bid(), nbuffers);
218 assert(begin.block_offset() == 0);
222 typename ExtIterator::const_iterator prev_block = begin;
226 if (begin.block_offset() == 0) {
227 if (prev_block != begin) {
228 prev_block.block_externally_updated();
233 *outstream = generator();
238 typename ExtIterator::const_iterator out = begin;
240 while (out.block_offset())
247 if (prev_block != out)
248 prev_block.block_externally_updated();
273 template <
typename ExtIterator,
typename EqualityComparable>
274 ExtIterator
find(ExtIterator begin, ExtIterator end,
const EqualityComparable& value,
int_type nbuffers = 0)
284 nbuffers = 2 * config::get_instance()->disks_number();
287 buf_istream_type in(begin.bid(), end.bid() + ((end.block_offset()) ? 1 : 0), nbuffers);
289 ExtIterator cur = begin - begin.block_offset();
292 for ( ; cur != begin; ++cur)
296 for ( ; cur != end; ++cur)
298 typename ExtIterator::value_type tmp;
311 #endif // !STXXL_ALGO_SCAN_HEADER
_Self & flush()
Force flush of current block, for finishing writing within a block.
UnaryFunction for_each(ExtIterator begin, ExtIterator end, UnaryFunction functor, int_type nbuffers=0)
External equivalent of std::for_each, see stxxl::for_each.
UnaryFunction for_each_m(ExtIterator begin, ExtIterator end, UnaryFunction functor, int_type nbuffers=0)
External equivalent of std::for_each (mutating), see stxxl::for_each_m (mutating).
choose_int_types< my_pointer_size >::int_type int_type
void generate(ExtIterator begin, ExtIterator end, Generator generator, int_type nbuffers=0)
External equivalent of std::generate, see stxxl::generate.
#define STXXL_BEGIN_NAMESPACE
ExtIterator find(ExtIterator begin, ExtIterator end, const EqualityComparable &value, int_type nbuffers=0)
External equivalent of std::find, see stxxl::find.
#define STXXL_END_NAMESPACE