Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

reverse_copy


Algorithm

Summary

Reverses the order of elements in a collection while copying them to a new collection.

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

None

Synopsis

#include <algorithm>
template <class BidirectionalIterator, class OutputIterator>
OutputIterator reverse_copy (BidirectionalIterator first,
                             BidirectionalIterator last,
                             OutputIterator result);

Description

The reverse_copy algorithm copies the range [first, last) to the range [result, result + (last - first)) such that for any non- negative integer i < (last - first), the following assignment takes place:

*(result + (last - first) -i) = *(first + i)

reverse_copy returns result + (last - first). The ranges [first, last) and [result, result + (last - first)) must not overlap.

Complexity

reverse_copy performs exactly (last - first) assignments.

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

reverse



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