Search code examples
c++stxxl

Combining Streams and Iteration in STXXL


STXXL supports a streaming model of data processing. STXXL data can either be processed by iterating through it (e.g. using stxxl::for_each), or by converting to a stream mode (e.g. using streamify() where such stream transforms can be composed for efficient processing. The stream results can be converted back to iterators using materialize().

I have a bunch of stream transforms, that I want to apply to an input stream. However, I do not need to store the result in any output "container".
What I need is a materialize-like function that just drives the stream without taking any output iterators - essentially like stxxl::for_each.
Is there such a similar function in STXXL?

Naturally, I can write custom "do-nothing"-output-iterators and pass these to materialize(), but I am wondering if there is a more elegant solution.


Solution

  • There is stxxl::stream::discard. Which takes a stream and throws away the results.