15 #ifndef STXXL_ALGO_SCAN_HEADER
16 #define STXXL_ALGO_SCAN_HEADER
49 template <
typename ExtIterator,
typename UnaryFunction>
50 UnaryFunction
for_each(ExtIterator begin, ExtIterator end,
51 UnaryFunction functor,
int_type nbuffers = 0)
56 typedef typename ExtIterator::value_type value_type;
59 typename ExtIterator::block_type,
60 typename ExtIterator::bids_container_iterator
66 nbuffers = 2 * config::get_instance()->disks_number();
69 buf_istream_type in(begin.bid(), end.bid() + ((end.block_offset()) ? 1 : 0), nbuffers);
71 ExtIterator cur = begin - begin.block_offset();
74 for ( ; cur != begin; ++cur)
81 for ( ; cur != end; ++cur)
89 if (end.block_offset())
91 ExtIterator last_block_end = end - end.block_offset() + ExtIterator::block_type::size;
92 for ( ; cur != last_block_end; ++cur)
124 template <
typename ExtIterator,
typename UnaryFunction>
126 UnaryFunction functor,
int_type nbuffers = 0)
131 typedef typename ExtIterator::value_type value_type;
134 typename ExtIterator::block_type,
135 typename ExtIterator::bids_container_iterator
139 typename ExtIterator::block_type,
140 typename ExtIterator::bids_container_iterator
146 nbuffers = 2 * config::get_instance()->disks_number();
149 buf_istream_type in(begin.bid(), end.bid() + ((end.block_offset()) ? 1 : 0), nbuffers / 2);
151 buf_ostream_type out(begin.bid(), nbuffers / 2);
155 ExtIterator cur = begin - begin.block_offset();
158 for ( ; cur != begin; ++cur)
166 for ( ; cur != end; ++cur)
175 if (end.block_offset())
177 ExtIterator _last_block_end = end - end.block_offset() + ExtIterator::block_type::size;
178 for ( ; cur != _last_block_end; ++cur)
206 template <
typename ExtIterator,
typename Generator>
208 Generator generator,
int_type nbuffers = 0)
210 typedef typename ExtIterator::block_type block_type;
213 block_type,
typename ExtIterator::bids_container_iterator
216 while (begin.block_offset())
222 *begin = generator();
229 nbuffers = 2 * config::get_instance()->disks_number();
232 buf_ostream_type outstream(begin.bid(), nbuffers);
234 assert(begin.block_offset() == 0);
238 typename ExtIterator::const_iterator prev_block = begin;
242 if (begin.block_offset() == 0) {
243 if (prev_block != begin) {
244 prev_block.block_externally_updated();
249 *outstream = generator();
254 typename ExtIterator::const_iterator out = begin;
256 while (out.block_offset())
263 if (prev_block != out)
264 prev_block.block_externally_updated();
288 template <
typename ExtIterator,
typename EqualityComparable>
289 ExtIterator
find(ExtIterator begin, ExtIterator end,
290 const EqualityComparable& value,
int_type nbuffers = 0)
296 typename ExtIterator::block_type,
297 typename ExtIterator::bids_container_iterator
303 nbuffers = 2 * config::get_instance()->disks_number();
306 buf_istream_type in(begin.bid(), end.bid() + ((end.block_offset()) ? 1 : 0), nbuffers);
308 ExtIterator cur = begin - begin.block_offset();
311 for ( ; cur != begin; ++cur)
315 for ( ; cur != end; ++cur)
317 typename ExtIterator::value_type tmp;
330 #endif // !STXXL_ALGO_SCAN_HEADER
self_type & 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