13 #ifndef STXXL_SCAN_HEADER
14 #define STXXL_SCAN_HEADER
16 #include <stxxl/bits/namespace.h>
17 #include <stxxl/bits/mng/buf_istream.h>
18 #include <stxxl/bits/mng/buf_ostream.h>
21 __STXXL_BEGIN_NAMESPACE
35 template <
typename _ExtIterator,
typename _UnaryFunction>
36 _UnaryFunction
for_each(_ExtIterator _begin, _ExtIterator _end, _UnaryFunction _functor, int_type nbuffers)
43 buf_istream_type in(_begin.bid(), _end.bid() + ((_end.block_offset()) ? 1 : 0), nbuffers / 2);
45 _ExtIterator _cur = _begin - _begin.block_offset();
48 for ( ; _cur != _begin; ++_cur)
50 typename _ExtIterator::value_type tmp;
55 for ( ; _cur != _end; ++_cur)
57 typename _ExtIterator::value_type tmp;
63 if (_end.block_offset())
65 _ExtIterator _last_block_end = _end - _end.block_offset() + _ExtIterator::block_type::size;
66 for ( ; _cur != _last_block_end; ++_cur)
68 typename _ExtIterator::value_type tmp;
86 template <
typename _ExtIterator,
typename _UnaryFunction>
87 _UnaryFunction
for_each_m(_ExtIterator _begin, _ExtIterator _end, _UnaryFunction _functor, int_type nbuffers)
95 buf_istream_type in(_begin.bid(), _end.bid() + ((_end.block_offset()) ? 1 : 0), nbuffers / 2);
97 buf_ostream_type out(_begin.bid(), nbuffers / 2);
101 _ExtIterator _cur = _begin - _begin.block_offset();
104 for ( ; _cur != _begin; ++_cur)
106 typename _ExtIterator::value_type tmp;
112 for ( ; _cur != _end; ++_cur)
114 typename _ExtIterator::value_type tmp;
121 if (_end.block_offset())
123 _ExtIterator _last_block_end = _end - _end.block_offset() + _ExtIterator::block_type::size;
124 for ( ; _cur != _last_block_end; ++_cur)
126 typename _ExtIterator::value_type tmp;
142 template <
typename _ExtIterator,
typename _Generator>
143 void generate(_ExtIterator _begin, _ExtIterator _end, _Generator _generator, int_type nbuffers)
145 typedef typename _ExtIterator::block_type block_type;
149 while (_begin.block_offset())
155 *_begin = _generator();
162 buf_ostream_type outstream(_begin.bid(), nbuffers);
164 assert(_begin.block_offset() == 0);
166 while (_end != _begin)
168 if (_begin.block_offset() == 0)
171 *outstream = _generator();
176 typename _ExtIterator::const_iterator out = _begin;
178 while (out.block_offset())
195 template <
typename _ExtIterator,
typename _EqualityComparable>
196 _ExtIterator
find(_ExtIterator _begin, _ExtIterator _end,
const _EqualityComparable & _value, int_type nbuffers)
203 buf_istream_type in(_begin.bid(), _end.bid() + ((_end.block_offset()) ? 1 : 0), nbuffers);
205 _ExtIterator _cur = _begin - _begin.block_offset();
208 for ( ; _cur != _begin; ++_cur)
213 for ( ; _cur != _end; ++_cur)
215 typename _ExtIterator::value_type tmp;
226 __STXXL_END_NAMESPACE
228 #endif // !STXXL_SCAN_HEADER