15 #ifndef STXXL_STREAM_STREAM_HEADER
16 #define STXXL_STREAM_STREAM_HEADER
27 #ifndef STXXL_VERBOSE_MATERIALIZE
28 #define STXXL_VERBOSE_MATERIALIZE STXXL_VERBOSE3
70 template <
class InputIterator_>
73 InputIterator_ current_,
end_;
77 typedef typename std::iterator_traits<InputIterator_>::value_type
value_type;
80 current_(begin), end_(end) { }
98 assert(end_ != current_);
106 return (current_ == end_);
115 template <
class InputIterator_>
122 template <
class InputIterator_>
133 template <
class InputIterator_>
137 typedef buf_istream<
typename InputIterator_::block_type,
152 typedef typename std::iterator_traits<InputIterator_>::value_type
value_type;
161 typename InputIterator_::bids_container_iterator end_iter = end.bid() + ((end.block_offset()) ? 1 : 0);
163 if (end_iter - begin.bid() > 0)
166 (2 * config::get_instance()->disks_number())));
168 InputIterator_ cur = begin - begin.block_offset();
171 for ( ; cur != begin; ++cur)
177 current_(a.current_), end_(a.end_), in(a.in.release()) { }
193 assert(end_ != current_);
205 return (current_ == end_);
221 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
222 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_>
223 vector_iterator2stream<stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_> >
231 (begin, end, nbuffers);
234 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
235 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_>
249 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
250 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_>
257 STXXL_VERBOSE1(
"streamify for const_vector_iterator range is called");
259 (begin, end, nbuffers);
262 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
263 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_>
276 template <
class InputIterator_>
288 typedef typename std::iterator_traits<InputIterator_>::value_type
value_type;
292 if (end - begin < block_type::size)
294 STXXL_VERBOSE1(
"vector_iterator2stream_sr::vector_iterator2stream_sr: Choosing iterator2stream<InputIterator_>");
296 vec_it_stream = NULL;
300 STXXL_VERBOSE1(
"vector_iterator2stream_sr::vector_iterator2stream_sr: Choosing vector_iterator2stream<InputIterator_>");
314 return **vec_it_stream;
320 return &(**it_stream);
322 return &(**vec_it_stream);
342 return it_stream->empty();
344 return vec_it_stream->empty();
352 delete vec_it_stream;
357 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
358 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_>
359 vector_iterator2stream_sr<stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_> >
365 STXXL_VERBOSE1(
"streamify_sr for vector_iterator range is called");
367 (begin, end, nbuffers);
371 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
372 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_>
373 vector_iterator2stream_sr<stxxl::const_vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_> >
379 STXXL_VERBOSE1(
"streamify_sr for const_vector_iterator range is called");
381 (begin, end, nbuffers);
395 template <
class OutputIterator_,
class StreamAlgorithm_>
396 OutputIterator_
materialize(StreamAlgorithm_& in, OutputIterator_ out)
418 template <
class OutputIterator_,
class StreamAlgorithm_>
419 OutputIterator_
materialize(StreamAlgorithm_& in, OutputIterator_ outbegin, OutputIterator_ outend)
422 while ((!in.empty()) && outend != outbegin)
443 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
444 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_,
class StreamAlgorithm_>
460 if (in.empty() || outbegin == outend)
469 nbuffers = 2 * config::get_instance()->disks_number();
474 buf_ostream_type outstream(outbegin.
bid(), nbuffers);
480 ConstExtIterator prev_block = outbegin;
482 while (!in.empty() && outend != outbegin)
485 if (prev_block != outbegin) {
487 prev_block = outbegin;
497 ConstExtIterator const_out = outbegin;
499 while (const_out.block_offset())
501 *outstream = *const_out;
506 if (prev_block != outbegin)
523 template <
typename Tp_,
typename AllocStr_,
typename SzTp_,
typename DiffTp_,
524 unsigned BlkSize_,
typename PgTp_,
unsigned PgSz_,
class StreamAlgorithm_>
552 nbuffers = 2 * config::get_instance()->disks_number();
558 buf_ostream_type outstream(out.
bid(), nbuffers);
564 ConstExtIterator prev_block = out;
569 if (prev_block != out) {
582 ConstExtIterator const_out = out;
585 while (const_out.block_offset())
587 *outstream = *const_out;
592 if (prev_block != out)
605 template <
class StreamAlgorithm_>
623 template <
class Generator_,
typename T =
typename Generator_::value_type>
636 gen_(g), current_(gen_()) { }
668 template <
class Generator_>
691 template <
class Operation_,
718 transform(Operation_& o, Input1_& i1_, Input2_& i2_, Input3_& i3_, Input4_& i4_,
719 Input5_& i5_, Input5_& i6_) :
720 op(o), i1(i1_), i2(i2_), i3(i3_), i4(i4_), i5(i5_), i6(i6_)
723 current = op(*i1, *i2, *i3, *i4, *i5, *i6);
747 current = op(*i1, *i2, *i3, *i4, *i5, *i6);
755 return i1.empty() || i2.empty() || i3.empty() ||
756 i4.empty() || i5.empty() || i6.empty();
772 template <
class Operation_,
835 template <
class Operation_,
854 transform(Operation_& o, Input1_& i1_, Input2_& i2_) : op(o), i1(i1_), i2(i2_)
857 current = op(*i1, *i2);
877 current = op(*i1, *i2);
885 return i1.empty() || i2.empty();
902 template <
class Operation_,
923 transform(Operation_& o, Input1_& i1_, Input2_& i2_, Input3_& i3_) :
924 op(o), i1(i1_), i2(i2_), i3(i3_)
927 current = op(*i1, *i2, *i3);
948 current = op(*i1, *i2, *i3);
956 return i1.empty() || i2.empty() || i3.empty();
974 template <
class Operation_,
997 transform(Operation_& o, Input1_& i1_, Input2_& i2_, Input3_& i3_, Input4_& i4_) :
998 op(o), i1(i1_), i2(i2_), i3(i3_), i4(i4_)
1001 current = op(*i1, *i2, *i3, *i4);
1023 current = op(*i1, *i2, *i3, *i4);
1031 return i1.empty() || i2.empty() || i3.empty() || i4.empty();
1050 template <
class Operation_,
1075 transform(Operation_& o, Input1_& i1_, Input2_& i2_, Input3_& i3_, Input4_& i4_,
1077 op(o), i1(i1_), i2(i2_), i3(i3_), i4(i4_), i5(i5_)
1080 current = op(*i1, *i2, *i3, *i4, *i5);
1103 current = op(*i1, *i2, *i3, *i4, *i5);
1111 return i1.empty() || i2.empty() || i3.empty() || i4.empty() || i5.empty();
1128 template <
class Input1_,
1130 class Input3_ = Stopper,
1131 class Input4_ = Stopper,
1132 class Input5_ = Stopper,
1133 class Input6_ = Stopper
1147 typename Input1_::value_type,
1148 typename Input2_::value_type,
1149 typename Input3_::value_type,
1150 typename Input4_::value_type,
1151 typename Input5_::value_type,
1152 typename Input6_::value_type
1168 i1(i1_), i2(i2_), i3(i3_), i4(i4_), i5(i5_), i6(i6_)
1171 current =
value_type(*i1, *i2, *i3, *i4, *i5, *i6);
1196 current =
value_type(*i1, *i2, *i3, *i4, *i5, *i6);
1204 return i1.empty() || i2.empty() || i3.empty() ||
1205 i4.empty() || i5.empty() || i6.empty();
1215 template <
class Input1_,
1226 typename Input1_::value_type,
1227 typename Input2_::value_type
1271 return i1.empty() || i2.empty();
1281 template <
class Input1_,
1294 typename Input1_::value_type,
1295 typename Input2_::value_type,
1296 typename Input3_::value_type
1309 i1(i1_), i2(i2_), i3(i3_)
1342 return i1.empty() || i2.empty() || i3.empty();
1353 template <
class Input1_,
1368 typename Input1_::value_type,
1369 typename Input2_::value_type,
1370 typename Input3_::value_type,
1371 typename Input4_::value_type
1385 i1(i1_), i2(i2_), i3(i3_), i4(i4_)
1419 return i1.empty() || i2.empty() || i3.empty() ||
1450 typename Input1_::value_type,
1451 typename Input2_::value_type,
1452 typename Input3_::value_type,
1453 typename Input4_::value_type,
1454 typename Input5_::value_type
1469 i1(i1_), i2(i2_), i3(i3_), i4(i4_), i5(i5_)
1472 current =
value_type(*i1, *i2, *i3, *i4, *i5);
1496 current =
value_type(*i1, *i2, *i3, *i4, *i5);
1504 return i1.empty() || i2.empty() || i3.empty() ||
1505 i4.empty() || i5.empty();
1521 #endif // !STXXL_STREAM_STREAM_HEADER
Const external vector iterator, model of ext_random_access_iterator concept.
bool empty() const
Standard stream method.
stxxl::tuple< typename Input1_::value_type, typename Input2_::value_type, typename Input3_::value_type, typename Input4_::value_type, typename Input5_::value_type, typename Input6_::value_type > value_type
Standard stream typedef.
vector_iterator2stream_sr< stxxl::vector_iterator< Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_ > > streamify_sr(stxxl::vector_iterator< Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_ > begin, stxxl::vector_iterator< Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_ > end, unsigned_type nbuffers=0)
Version of streamify. Switches from vector_iterator2stream to iterator2stream for small ranges...
bool empty() const
Standard stream method.
generator2stream(Generator_ g)
virtual ~vector_iterator2stream_sr()
#define STXXL_VERBOSE_MATERIALIZE
A model of stream that retrieves the data from an input iterator. For convenience use streamify funct...
Traits class of streamify function.
vector_iterator2stream(const Self_ &a)
iterator2stream< InputIterator_ > stream_type
return type (stream type) of streamify for InputIterator_.
std::auto_ptr< _Tp > result
bool empty() const
Standard stream method.
Version of iterator2stream. Switches between vector_iterator2stream and iterator2stream ...
vector_iterator2stream< InputIterator_ > Self_
uint_pair & operator++()
prefix increment operator (directly manipulates the integer parts)
iterator2stream(const iterator2stream &a)
InputIterator_::block_type block_type
buf_istream_unique_ptr_type in
vector_iterator2stream< InputIterator_ > * vec_it_stream
vector_iterator2stream(InputIterator_ begin, InputIterator_ end, unsigned_type nbuffers=0)
A model of stream that retrieves data from an external stxxl::vector iterator. It is more efficient t...
std::iterator_traits< InputIterator_ >::value_type value_type
Standard stream typedef.
Creates stream of 6-tuples from 6 input streams.
A model of stream that outputs data from an adaptable generator functor. For convenience use streamif...
iterator2stream< InputIterator_ > * it_stream
bool empty() const
Standard stream method.
buf_istream< typename InputIterator_::block_type, typename InputIterator_::bids_container_iterator > buf_istream_type
vector_iterator2stream_sr< InputIterator_ > Self_
T value_type
Standard stream typedef.
#define STXXL_BEGIN_NAMESPACE
OutputIterator_ materialize(StreamAlgorithm_ &in, OutputIterator_ out)
Stores consecutively stream content to an output iterator.
vector_iterator2stream_sr(InputIterator_ begin, InputIterator_ end, unsigned_type nbuffers=0)
#define STXXL_VERBOSE1(x)
External vector iterator, model of ext_random_access_iterator concept.
vector_iterator2stream_sr(const Self_ &a)
vector_iterator2stream< stxxl::const_vector_iterator< Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_ > > stream_type
bids_container_iterator bid() const
return iterator to BID containg current element
choose_int_types< my_pointer_size >::unsigned_type unsigned_type
block_offset_type block_offset() const
return block offset of current element
generator2stream(const generator2stream &a)
void discard(StreamAlgorithm_ &in)
Reads stream content and discards it. Useful where you do not need the processed stream anymore...
vector_iterator2stream< stxxl::vector_iterator< Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_ > > stream_type
void block_externally_updated()
make_tuple(Input1_ &i1_, Input2_ &i2_, Input3_ &i3_, Input4_ &i4_, Input5_ &i5_, Input6_ &i6_)
Construction.
std::iterator_traits< InputIterator_ >::value_type value_type
Standard stream typedef.
virtual ~vector_iterator2stream()
stxxl::compat_unique_ptr< buf_istream_type >::result buf_istream_unique_ptr_type
iterator2stream< InputIterator_ > streamify(InputIterator_ begin, InputIterator_ end)
Input iterator range to stream converter.
std::iterator_traits< InputIterator_ >::value_type value_type
Standard stream typedef.
#define STXXL_PRETTY_FUNCTION_NAME
iterator2stream(InputIterator_ begin, InputIterator_ end)
#define STXXL_END_NAMESPACE
bool empty() const
Standard stream method.