|
ALINK="#ff0000">
reverse_copy
Prototypetemplate <class BidirectionalIterator, class OutputIterator> OutputIterator reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result); DescriptionReverse_copy copies elements from the range [first, last) to the range [result, result + (last - first)) such that the copy is a reverse of the original range. Specifically: for every i such that 0 <= i < (last - first), reverse_copy performs the assignment *(result + (last - first) - i) = *(first + i).The return value is result + (last - first). DefinitionDefined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.Requirements on types
Preconditions
ComplexityLinear: exactly last - first assignments.Examplevector<int> V; V.push_back(0); V.push_back(1); V.push_back(2); copy(V.begin(), V.end(), ostream_iterator<int>(cout, " ")); // Output: 0 1 2 list<int> L(V.size()); reverse_copy(V.begin(), V.end(), L.begin()); copy(L.begin(), L.end(), ostream_iterator<int>(cout, " ")); // Output: 2 1 0 NotesSee alsoreverse, copyCopyright © 1999 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation
|