STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Author
Roman Dementiev (2006)

The semantics of the algorithm are equivalent to the STL std::generate.

Prototype

template < typename ExtIterator, typename Generator >
void generate ( ExtIterator first,
ExtIterator last,
Generator generator,
int_type nbuffers
)

Description

Generate assigns the result of invoking generator, a function object that takes no arguments, to each element in the range [first, last). To overlap I/O and computation nbuffers are used (a value at least D is recommended). The size of the buffers is derived from the container that is pointed by the iterators.

Remarks
The implementation exploits STXXL buffered streams (computation and I/O overlapped).
Parameters
beginobject of model of ext_random_access_iterator concept
endobject of model of ext_random_access_iterator concept
generatorfunction object of model of std::generator concept
nbuffersnumber of buffers (blocks) for internal use (should be at least 2*D, or zero for automaticl 2*D)

Requirements on types

  • ExtIterator is a model of External Random Access Iterator.
  • ExtIterator is mutable.
  • Generator is a model of a STL Generator.
  • Generator's result type is convertible to ExtIterator's value type.

Preconditions

[first, last) is a valid range.

Complexity

  • Internal work is linear.
  • External work: close to $ N/DB $ I/Os (write-only).

Example

// Fill a vector with random numbers, using the
// standard C library function rand.
vector_type V(some_size);
// use 20 buffer blocks
stxxl::generate(V.begin(), V.end(), rand, 20);