My Project
stxxl::for_each
Author
Roman Dementiev (2006)

The semantics of the algorithm is equivalent to the STL std::for_each.

Prototype

template < typename ExtIterator, typename UnaryFunction >
UnaryFunction for_each ( ExtIterator first,
ExtIterator last,
UnaryFunction functor,
int_type nbuffers
)

Description

Requirements on types

Preconditions

[first, last) is a valid range.

Complexity

Example

template<class T>
struct print : public unary_function<T, void>
{
print(ostream& out) : os(out), count(0) {}
void operator() (T x) { os << x << ' '; ++count; }
ostream& os;
int count;
};
typedef stxxl::VECTOR_GENERATOR<int>::result vector_type;
int main()
{
vector_type A(N);
// fill A with some values
// ...
print<int> P = stxxl::for_each(A.begin(), A.end(), print<int>(cout));
cout << endl << P.count << " objects printed." << endl;
}