fill
Replaces each element with a given value
Definition
The fill() algorithm is defined in the standard header <algorithm> and in the nonstandard backward-compatibility header <algo.h>.
Interface
#include <algorithm>
template < class ForwardIterator, class Type >
void fill(
ForwardIterator first,
ForwardIterator last,
const Type& val
);Parameters:
| Parameter | Description |
| first | A forward iterator addressing the position of the first element in the range to be traversed |
| last | A forward iterator addressing the position one past the final element in the range to be traversed |
| val | The value to be assigned to elements in the range [first, last) |
Description
Fill algorithm fills a range with a given value by using operator=.
Return Value
None.
Complexity
The complexity is linear; performs (last - first) assignments.
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_n.php"fill_n"
- http://www.codecogs.com/reference/computing/stl/algorithms/modifying/generate.php"generate"
- http://www.codecogs.com/reference/computing/stl/algorithms/modifying/generate_n.php"generate_n"
CodeCogs®