- Author
- Roman Dementiev (2006)
stxxl::for_each_m is a mutating version of stxxl::for_each, i.e. the restriction that Unary Function functor
can not apply only constant operations through its argument does not exist.
Prototype
template < typename ExtIterator, typename UnaryFunction >
UnaryFunction for_each_m ( ExtIterator first,
ExtIterator last,
UnaryFunction functor,
int nbuffers
)
Description
Requirements on types
ExtIterator
is a model of External Random Access Iterator.
UnaryFunction
is a model of STL Unary Function.
ExtIterator's
value type is convertible to UnaryFunction's
argument type.
Preconditions
[first, last) is a valid range.
Complexity
- Internal work is linear.
- External work: close to
I/Os (read and write).
Example
struct AddX
{
int x;
AddX(int x_): x(x_) {}
void operator() (int & val)
{ val += x; }
};
typedef stxxl::VECTOR_GENERATOR<int>::result vector_type;
int main()
{
vector_type A(N);
stxxl::for_each_m(A.begin(), A.end(), AddX(5));
}