generate
Replaces each element with the result of an operation
Definition
The generate() algorithm is defined in the standard header <algorithm> and in the nonstandard backward-compatibility header <algo.h>.
Interface
#include <algorithm>
template < class ForwardIterator, class Generator >
void generate(
ForwardIterator first,
ForwardIterator last,
Generator gen
);Parameters:
| Parameter | Description |
| first | A forward iterator addressing the position of the first element in the range to which values are to be assigned |
| last | A forward iterator addressing the position one past the final element in the range to which values are to be assigned |
| gen | A function object that is called with no arguments that is used to generate the values to be assigned to each of the elements in the range |
Description
Generate algorithm uses a generator to generate each element of a range.
Return Value
None.
Complexity
The complexity is linear with last - first invocations of gen.
References
See Also
- http://www.codecogs.com/reference/computing/stl/algorithms/modifying/copy.php"copy"
- http://www.codecogs.com/reference/computing/stl/algorithms/modifying/fill.php"fill"
- http://www.codecogs.com/reference/computing/stl/algorithms/modifying/fill_n.php"fill_n"
- http://www.codecogs.com/reference/computing/stl/algorithms/modifying/generate_n.php"generate_n"
CodeCogs®