14 #ifndef STXXL_SCAN_HEADER
15 #define STXXL_SCAN_HEADER
17 #include <stxxl/bits/namespace.h>
18 #include <stxxl/bits/mng/buf_istream.h>
19 #include <stxxl/bits/mng/buf_ostream.h>
22 __STXXL_BEGIN_NAMESPACE
36 template <
typename _ExtIterator,
typename _UnaryFunction>
37 _UnaryFunction
for_each(_ExtIterator _begin, _ExtIterator _end, _UnaryFunction _functor, int_type nbuffers)
47 buf_istream_type in(_begin.bid(), _end.bid() + ((_end.block_offset()) ? 1 : 0), nbuffers);
49 _ExtIterator _cur = _begin - _begin.block_offset();
52 for ( ; _cur != _begin; ++_cur)
54 typename _ExtIterator::value_type tmp;
59 for ( ; _cur != _end; ++_cur)
61 typename _ExtIterator::value_type tmp;
67 if (_end.block_offset())
69 _ExtIterator _last_block_end = _end - _end.block_offset() + _ExtIterator::block_type::size;
70 for ( ; _cur != _last_block_end; ++_cur)
72 typename _ExtIterator::value_type tmp;
90 template <
typename _ExtIterator,
typename _UnaryFunction>
91 _UnaryFunction
for_each_m(_ExtIterator _begin, _ExtIterator _end, _UnaryFunction _functor, int_type nbuffers)
102 buf_istream_type in(_begin.bid(), _end.bid() + ((_end.block_offset()) ? 1 : 0), nbuffers / 2);
104 buf_ostream_type out(_begin.bid(), nbuffers / 2);
108 _ExtIterator _cur = _begin - _begin.block_offset();
111 for ( ; _cur != _begin; ++_cur)
113 typename _ExtIterator::value_type tmp;
119 for ( ; _cur != _end; ++_cur)
121 typename _ExtIterator::value_type tmp;
128 if (_end.block_offset())
130 _ExtIterator _last_block_end = _end - _end.block_offset() + _ExtIterator::block_type::size;
131 for ( ; _cur != _last_block_end; ++_cur)
133 typename _ExtIterator::value_type tmp;
149 template <
typename _ExtIterator,
typename _Generator>
150 void generate(_ExtIterator _begin, _ExtIterator _end, _Generator _generator, int_type nbuffers)
152 typedef typename _ExtIterator::block_type block_type;
156 while (_begin.block_offset())
162 *_begin = _generator();
169 buf_ostream_type outstream(_begin.bid(), nbuffers);
171 assert(_begin.block_offset() == 0);
175 typename _ExtIterator::const_iterator prev_block = _begin;
177 while (_end != _begin)
179 if (_begin.block_offset() == 0) {
180 if (prev_block != _begin) {
181 prev_block.block_externally_updated();
186 *outstream = _generator();
191 typename _ExtIterator::const_iterator out = _begin;
193 while (out.block_offset())
200 if (prev_block != out)
201 prev_block.block_externally_updated();
214 template <
typename _ExtIterator,
typename _EqualityComparable>
215 _ExtIterator
find(_ExtIterator _begin, _ExtIterator _end,
const _EqualityComparable & _value, int_type nbuffers)
225 buf_istream_type in(_begin.bid(), _end.bid() + ((_end.block_offset()) ? 1 : 0), nbuffers);
227 _ExtIterator _cur = _begin - _begin.block_offset();
230 for ( ; _cur != _begin; ++_cur)
235 for ( ; _cur != _end; ++_cur)
237 typename _ExtIterator::value_type tmp;
248 __STXXL_END_NAMESPACE
250 #endif // !STXXL_SCAN_HEADER
Buffered input stream.
Definition: buf_istream.h:36
_UnaryFunction for_each_m(_ExtIterator _begin, _ExtIterator _end, _UnaryFunction _functor, int_type nbuffers)
External equivalent of std::for_each (mutating)
Definition: scan.h:91
void generate(_ExtIterator _begin, _ExtIterator _end, _Generator _generator, int_type nbuffers)
External equivalent of std::generate.
Definition: scan.h:150
_UnaryFunction for_each(_ExtIterator _begin, _ExtIterator _end, _UnaryFunction _functor, int_type nbuffers)
External equivalent of std::for_each.
Definition: scan.h:37
Buffered output stream.
Definition: buf_ostream.h:30
_ExtIterator find(_ExtIterator _begin, _ExtIterator _end, const _EqualityComparable &_value, int_type nbuffers)
External equivalent of std::find.
Definition: scan.h:215