Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Mutating Algorithms
[Algorithms]


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)

Detailed Description

Algorithms for modifying your data in some way.

Function Documentation

template<typename InputIterator, typename OutputIterator>
OutputIterator copy InputIterator  first,
InputIterator  last,
OutputIterator  result
[inline]
 

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.

template<typename InputIterator, typename OutputIterator>
OutputIterator copy_backward InputIterator  first,
InputIterator  last,
OutputIterator  result
[inline]
 

Copy copies elements from the range (last, first] to result.

Copies elements starting at last, decrementing both last and result.

template<typename InputIterator, typename OutputIterator>
OutputIterator copy_n InputIterator  first,
size_t  count,
OutputIterator  result
[inline]
 

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.

template<typename InputIterator, typename UnaryFunction>
UnaryFunction for_each InputIterator  first,
InputIterator  last,
UnaryFunction  f
[inline]
 

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.

template<typename ForwardIterator, typename Generator>
void generate ForwardIterator  first,
ForwardIterator  last,
Generator  gen
[inline]
 

Generate assigns the result of invoking gen, a function object that takes no arguments, to each element in the range [first, last).

template<typename OutputIterator, typename Generator>
OutputIterator generate_n OutputIterator  first,
size_t  n,
Generator  gen
[inline]
 

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.

template<typename Container>
void random_shuffle Container &  ctr  )  [inline]
 

Randomly permute the elements of the container.

template<typename RandomAccessIterator>
void random_shuffle RandomAccessIterator  first,
RandomAccessIterator  last
[inline]
 

Randomly permute the elements of the container.

template<typename ForwardIterator, typename T>
ForwardIterator remove ForwardIterator  first,
ForwardIterator  last,
const T &  value
[inline]
 

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.

template<typename InputIterator, typename OutputIterator, typename RInputIterator>
OutputIterator remove_copy InputIterator  first,
InputIterator  last,
OutputIterator  result,
RInputIterator  rfirst,
RInputIterator  rlast
 

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.

template<typename InputIterator, typename OutputIterator, typename T>
OutputIterator remove_copy InputIterator  first,
InputIterator  last,
OutputIterator  result,
const T &  value
[inline]
 

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).

template<typename ForwardIterator, typename T>
void replace ForwardIterator  first,
ForwardIterator  last,
const T &  old_value,
const T &  new_value
[inline]
 

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.

template<typename InputIterator, typename OutputIterator, typename T>
OutputIterator replace_copy InputIterator  first,
InputIterator  last,
OutputIterator  result,
const T &  old_value,
const T &  new_value
[inline]
 

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.

template<typename BidirectionalIterator>
void reverse BidirectionalIterator  first,
BidirectionalIterator  last
[inline]
 

Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)).

template<typename ForwardIterator>
ForwardIterator rotate ForwardIterator  first,
ForwardIterator  middle,
ForwardIterator  last
 

Exchanges ranges [first, middle) and [middle, last)

template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryFunction>
OutputIterator transform InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
OutputIterator  result,
BinaryFunction  op
[inline]
 

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).

template<typename InputIterator, typename OutputIterator, typename UnaryFunction>
OutputIterator transform InputIterator  first,
InputIterator  last,
OutputIterator  result,
UnaryFunction  op
[inline]
 

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).

template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator unique ForwardIterator  first,
ForwardIterator  last,
BinaryPredicate  binary_pred
[inline]
 

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.

template<typename ForwardIterator>
ForwardIterator unique ForwardIterator  first,
ForwardIterator  last
[inline]
 

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.

template<typename InputIterator, typename OutputIterator, typename BinaryPredicate>
OutputIterator unique_copy InputIterator  first,
InputIterator  last,
OutputIterator  result,
BinaryPredicate  binary_pred
 

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.

template<typename InputIterator, typename OutputIterator>
OutputIterator unique_copy InputIterator  first,
InputIterator  last,
OutputIterator  result
 

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.


Generated on Mon Jan 17 14:35:02 2005 for uSTL by 1.3.9 Doxygen Hosted on SourceForge.net