fill_n
Replaces n elements with a given value
Definition
The fill_n() algorithm is defined in the standard header <algorithm> and in the nonstandard backward-compatibility header <algo.h>.
Interface
#include <algorithm>
template < class OutputIterator, class Size, class Type >
void fill_n(
OutputIterator first,
Size count,
const Type& val
);Parameters:
| Parameter | Description |
| first | An output iterator addressing the position of the first element in the range to be assigned the value val |
| count | A signed or unsigned integer type specifying the number of elements to be assigned the value |
| val | The value to be assigned to elements in the range [first, first + count) |
Description
Fill_n algorithm does the same thing that http://www.codecogs.com/reference/computing/stl/algorithms/modifying/fill.php"fill" but fills n elements.
Return Value
None.
Complexity
The complexity is linear; performs n 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.php"fill"
- 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"