Modules | |
group | Sorting Algorithms |
group | Generator Algorithms |
group | Swap Algorithms |
Functions | |
template<typename InputIterator, typename OutputIterator, typename UnaryFunction> | |
OutputIterator | ustl::transform (InputIterator first, InputIterator last, OutputIterator result, UnaryFunction op) |
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryFunction> | |
OutputIterator | ustl::transform (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryFunction op) |
template<typename ForwardIterator, typename T> | |
void | ustl::replace (ForwardIterator first, ForwardIterator last, const T &old_value, const T &new_value) |
template<typename InputIterator, typename OutputIterator, typename T> | |
OutputIterator | ustl::replace_copy (InputIterator first, InputIterator last, OutputIterator result, const T &old_value, const T &new_value) |
template<typename ForwardIterator, typename Generator> | |
void | ustl::generate (ForwardIterator first, ForwardIterator last, Generator gen) |
template<typename OutputIterator, typename Generator> | |
OutputIterator | ustl::generate_n (OutputIterator first, size_t n, Generator gen) |
template<typename BidirectionalIterator> | |
void | ustl::reverse (BidirectionalIterator first, BidirectionalIterator last) |
template<typename ForwardIterator> | |
ForwardIterator | ustl::rotate (ForwardIterator first, ForwardIterator middle, ForwardIterator last) |
template<typename InputIterator, typename OutputIterator, typename T> | |
OutputIterator | ustl::remove_copy (InputIterator first, InputIterator last, OutputIterator result, const T &value) |
template<typename InputIterator, typename OutputIterator, typename RInputIterator> | |
OutputIterator | ustl::remove_copy (InputIterator first, InputIterator last, OutputIterator result, RInputIterator rfirst, RInputIterator rlast) |
template<typename ForwardIterator, typename T> | |
ForwardIterator | ustl::remove (ForwardIterator first, ForwardIterator last, const T &value) |
template<typename InputIterator, typename OutputIterator> | |
OutputIterator | ustl::unique_copy (InputIterator first, InputIterator last, OutputIterator result) |
template<typename ForwardIterator> | |
ForwardIterator | ustl::unique (ForwardIterator first, ForwardIterator last) |
template<typename RandomAccessIterator> | |
void | ustl::random_shuffle (RandomAccessIterator first, RandomAccessIterator last) |
template<typename InputIterator, typename OutputIterator> | |
OutputIterator | ustl::copy (InputIterator first, InputIterator last, OutputIterator result) |
template<typename InputIterator, typename OutputIterator> | |
OutputIterator | ustl::copy_n (InputIterator first, size_t count, OutputIterator result) |
template<typename InputIterator, typename OutputIterator> | |
OutputIterator | ustl::copy_backward (InputIterator first, InputIterator last, OutputIterator result) |
Copy copies elements from the range (last, first] to result. | |
template<typename InputIterator, typename UnaryFunction> | |
UnaryFunction | ustl::for_each (InputIterator first, InputIterator last, UnaryFunction f) |
template<typename Container> | |
void | ustl::random_shuffle (Container &ctr) |
template<typename InputIterator, typename OutputIterator, typename BinaryPredicate> | |
OutputIterator | ustl::unique_copy (InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate binary_pred) |
template<typename ForwardIterator, typename BinaryPredicate> | |
ForwardIterator | ustl::unique (ForwardIterator first, ForwardIterator last, BinaryPredicate binary_pred) |
|
Copy copies elements from the range [first, last) to the range [result, result + (last - first)). That is, it performs the assignments result = *first, *(result + 1) = *(first + 1), and so on. [1] Generally, for every integer n from 0 to last - first, copy performs the assignment (result + n) = *(first + n). Assignments are performed in forward order, i.e. in order of increasing n. |
|
Copy copies elements from the range (last, first] to result. Copies elements starting at last, decrementing both last and result. |
|
Copy_n copies elements from the range [first, first + n) to the range [result, result + n). That is, it performs the assignments result = *first, *(result + 1) = *(first + 1), and so on. Generally, for every integer i from 0 up to (but not including) n, copy_n performs the assignment *(result + i) = *(first + i). Assignments are performed in forward order, i.e. in order of increasing n. |
|
For_each applies the function object f to each element in the range [first, last); f's return value, if any, is ignored. Applications are performed in forward order, i.e. from first to last. For_each returns the function object after it has been applied to each element. |
|
Generate assigns the result of invoking gen, a function object that takes no arguments, to each element in the range [first, last). |
|
Generate_n assigns the result of invoking gen, a function object that takes no arguments, to each element in the range [first, first+n). The return value is first + n. |
|
Randomly permute the elements of the container. |
|
Randomly permute the elements of the container. |
|
Remove removes from the range [first, last) all elements that are equal to value. That is, remove returns an iterator new_last such that the range [first, new_last) contains no elements equal to value. [1] The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Remove is stable, meaning that the relative order of elements that are not equal to value is unchanged. |
|
Remove_copy copies elements pointed to by iterators in [rfirst, rlast) from the range [first, last) to a range beginning at result. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last). Range [rfirst, rlast) is assumed to be sorted. This algorithm is a uSTL extension. |
|
Remove_copy copies elements that are not equal to value from the range [first, last) to a range beginning at result. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last). |
|
Replace replaces every element in the range [first, last) equal to old_value with new_value. That is: for every iterator i, if *i == old_value then it performs the assignment *i = new_value. |
|
Replace_copy copies elements from the range [first, last) to the range [result, result + (last-first)), except that any element equal to old_value is not copied; new_value is copied instead. More precisely, for every integer n such that 0 <= n < last-first, replace_copy performs the assignment *(result+n) = new_value if *(first+n) == old_value, and (result+n) = *(first+n) otherwise. |
|
Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)). |
|
Exchanges ranges [first, middle) and [middle, last) |
|
The second version of transform is very similar, except that it uses a Binary Function instead of a Unary Function: it performs the operation op(*i1, *i2) for each iterator i1 in the range [first1, last1) and assigns the result to *o, where i2 is the corresponding iterator in the second input range and where o is the corresponding output iterator. That is, for each n such that 0 <= n < last1 - first1, it performs the assignment (result + n) = op(*(first1 + n), *(first2 + n). The return value is result + (last1 - first1). |
|
The first version of transform performs the operation op(*i) for each iterator i in the range [first, last), and assigns the result of that operation to *o, where o is the corresponding output iterator. That is, for each n such that 0 <= n < last - first, it performs the assignment (result + n) = op(*(first + n)). The return value is result + (last - first). |
|
Every time a consecutive group of duplicate elements appears in the range [first, last), the algorithm unique removes all but the first element. That is, unique returns an iterator new_last such that the range [first, new_last) contains no two consecutive elements that are duplicates. The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Unique is stable, meaning that the relative order of elements that are not removed is unchanged. |
|
Every time a consecutive group of duplicate elements appears in the range [first, last), the algorithm unique removes all but the first element. That is, unique returns an iterator new_last such that the range [first, new_last) contains no two consecutive elements that are duplicates. The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Unique is stable, meaning that the relative order of elements that are not removed is unchanged. |
|
The reason there are two different versions of unique_copy is that there are two different definitions of what it means for a consecutive group of elements to be duplicates. In the first version, the test is simple equality: the elements in a range [f, l) are duplicates if, for every iterator i in the range, either i == f or else *i == *(i-1). In the second, the test is an arbitrary Binary Predicate binary_pred: the elements in [f, l) are duplicates if, for every iterator i in the range, either i == f or else binary_pred(*i, *(i-1)) is true. |
|
Unique_copy copies elements from the range [first, last) to a range beginning with result, except that in a consecutive group of duplicate elements only the first one is copied. The return value is the end of the range to which the elements are copied. This behavior is similar to the Unix filter uniq. |