Stxxl  1.4.0
stream/test_materialize.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  stream/test_materialize.cpp
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00007  *
00008  *  Distributed under the Boost Software License, Version 1.0.
00009  *  (See accompanying file LICENSE_1_0.txt or copy at
00010  *  http://www.boost.org/LICENSE_1_0.txt)
00011  **************************************************************************/
00012 
00013 #include <vector>
00014 #include <stxxl/stream>
00015 #include <stxxl/vector>
00016 
00017 struct forty_two
00018 {
00019     unsigned counter;
00020 
00021     forty_two() : counter(0) { }
00022 
00023     bool empty() const { return !(counter < 42); }
00024 
00025     int operator * ()
00026     {
00027         assert(!empty());
00028         return 42;
00029     }
00030 
00031     forty_two & operator ++ ()
00032     {
00033         assert(!empty());
00034         ++counter;
00035         return *this;
00036     }
00037 
00038     forty_two & reset()
00039     {
00040         counter = 0;
00041         return *this;
00042     }
00043 };
00044 
00045 /*
00046     template <class OutputIterator_, class StreamAlgorithm_>
00047     OutputIterator_ materialize(StreamAlgorithm_ & in, OutputIterator_ out);
00048 
00049     template <class OutputIterator_, class StreamAlgorithm_>
00050     OutputIterator_ materialize(StreamAlgorithm_ & in, OutputIterator_ outbegin, OutputIterator_ outend);
00051 
00052     template <typename Tp_, typename AllocStr_, typename SzTp_, typename DiffTp_,
00053               unsigned BlkSize_, typename PgTp_, unsigned PgSz_, class StreamAlgorithm_>
00054     stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_>
00055     materialize(StreamAlgorithm_ & in,
00056                 stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_> outbegin,
00057                 stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_> outend,
00058                 unsigned_type nbuffers = 0);
00059 
00060     template <typename Tp_, typename AllocStr_, typename SzTp_, typename DiffTp_,
00061               unsigned BlkSize_, typename PgTp_, unsigned PgSz_, class StreamAlgorithm_>
00062     stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_>
00063     materialize(StreamAlgorithm_ & in,
00064                 stxxl::vector_iterator<Tp_, AllocStr_, SzTp_, DiffTp_, BlkSize_, PgTp_, PgSz_> out,
00065                 unsigned_type nbuffers = 0);
00066 */
00067 
00068 int main()
00069 {
00070     stxxl::config::get_instance();
00071     forty_two _42;
00072     std::vector<int> v(1000);
00073     stxxl::stream::materialize(_42.reset(), v.begin());
00074     stxxl::stream::materialize(_42.reset(), v.begin(), v.end());
00075 
00076     stxxl::VECTOR_GENERATOR<int>::result xv(1000);
00077     stxxl::stream::materialize(_42.reset(), xv.begin());
00078     stxxl::stream::materialize(_42.reset(), xv.begin(), 42);
00079     stxxl::stream::materialize(_42.reset(), xv.begin(), xv.end());
00080     stxxl::stream::materialize(_42.reset(), xv.begin(), xv.end(), 42);
00081 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines