next up previous index
Next: Fill a range Up: Mutating sequence operations Previous: Replace specified elements

Fill a range with copies of a value

Source code

Declaration

template <class ForwardIterator, class T>
void fill(ForwardIterator first, ForwardIterator last, const T& value);

template <class OutputIterator, class T>
void fill_n(OutputIterator first, size_t n, const T& value);

Description    The fill  function fills  the range [ first, last) with copies of value.

The fill_n  function fills  the first n locations in the range [ first, last) with copies of value.

Type requirements

Group Mutating sequence operations.

Time complexity Linear.

The number of assignments is the size of the range [ first, last) for the fill  function, and n for the fill_n  function.

Space complexity Constant.

Mutative? Yes.

Example Select here to view the source code for the example.

 

Implementation Select here to view source code (Copyright (C) 1994, Hewlett-Packard Company) for this algorithm.



Kenny Zalewski
Mon May 13 04:03:40 EDT 1996