Binary Predicate,
reverse
Category: algorithms
Component type: function
template <class BidirectionalIterator>
void reverse(BidirectionalIterator first, BidirectionalIterator last);
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
• BidirectionalIterator is a model of Bidirectional Iterator.
• BidirectionalIterator is mutable.
Linear:
vector<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
reverse(V.begin(), V.end());
copy(V.begin(), V.end(), ostream_iterator<int>(cout, ' '));
// Output: 2 1 0
reverse_copy
Category: algorithms
Component type: function
template <class BidirectionalIterator, class OutputIterator>
OutputIterator reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
The return value is
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
• BidirectionalIterator is a model of Bidirectional Iterator.
• OutputIterator is a model of Output Iterator.
• The value type of BidirectionalIterator is convertible to a type in OutputIterator's set of value types.
• There is enough space to hold all of the elements being copied. More formally, the requirement is that
• The ranges
Linear: exactly
vector<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
rotate
Category: algorithms
Component type: function
template <class ForwardIterator>
inline ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
