Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

replace


Algorithm

Summary

Substitutes elements in a collection with new values.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

None

Synopsis

#include <algorithm>
template <class ForwardIterator, class T>
void replace (ForwardIterator first,
              ForwardIterator last,
              const T& old_value,
              const T& new_value);

Description

For the range [first, last), the replace algorithm replaces elements referred to by iterator i with new_value, when the following condition holds: *i == old_value.

Complexity

Exactly last - first comparisons or applications of the corresponding predicate are done.

Example

Program Output

Warnings

If your compiler does not support default template parameters, then you always need to supply the Allocator template argument. For instance, you need to write:

vector<int, allocator<int> >

instead of:

vector<int>

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

replace_if, replace_copy, replace_copy_if



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998