stl_algo.h File Reference

#include <bits/stl_heap.h>
#include <bits/stl_tempbuf.h>
#include <debug/debug.h>

Include dependency graph for stl_algo.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  std

Functions

template<typename Type>
const Type & __median (const Type &a, const Type &__b, const Type &c)
 Find the median of three values.
template<typename Type, typename Compare>
const Type & __median (const Type &a, const Type &__b, const Type &c, Compare comp)
 Find the median of three values using a predicate for comparison.
template<typename InputIterator, typename Function>
Function for_each (InputIterator first, InputIterator last, Function __f)
 Apply a function to every element of a sequence.
template<typename InputIterator, typename Type>
InputIterator find (InputIterator first, InputIterator last, const Type &__val)
 Find the first occurrence of a value in a sequence.
template<typename InputIterator, typename Predicate>
InputIterator find_if (InputIterator first, InputIterator last, Predicate pred)
 Find the first element in a sequence for which a predicate is true.
template<typename ForwardIterator>
ForwardIterator adjacent_find (ForwardIterator first, ForwardIterator last)
 Find two adjacent values in a sequence that are equal.
template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator adjacent_find (ForwardIterator first, ForwardIterator last, BinaryPredicate __binary_pred)
 Find two adjacent values in a sequence using a predicate.
template<typename InputIterator, typename Type>
iterator_traits< InputIterator
>::difference_type 
count (InputIterator first, InputIterator last, const Type &value)
 Count the number of copies of a value in a sequence.
template<typename InputIterator, typename Predicate>
iterator_traits< InputIterator
>::difference_type 
count_if (InputIterator first, InputIterator last, Predicate pred)
 Count the elements of a sequence for which a predicate is true.
template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2)
 Search a sequence for a matching sub-sequence.
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate predicate)
 Search a sequence for a matching sub-sequence using a predicate.
template<typename ForwardIterator, typename Integer, typename Type>
ForwardIterator search_n (ForwardIterator first, ForwardIterator last, Integer count, const Type &__val)
 Search a sequence for a number of consecutive values.
template<typename ForwardIterator, typename Integer, typename Type, typename BinaryPredicate>
ForwardIterator search_n (ForwardIterator first, ForwardIterator last, Integer count, const Type &__val, BinaryPredicate __binary_pred)
 Search a sequence for a number of consecutive values using a predicate.
template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator2 swap_ranges (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2)
 Swap the elements of two sequences.
template<typename InputIterator, typename OutputIterator, typename UnaryOperation>
OutputIterator transform (InputIterator first, InputIterator last, OutputIterator __result, UnaryOperation __unary_op)
 Perform an operation on a sequence.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryOperation>
OutputIterator transform (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator __result, BinaryOperation __binary_op)
 Perform an operation on corresponding elements of two sequences.
template<typename ForwardIterator, typename Type>
void replace (ForwardIterator first, ForwardIterator last, const Type &__old_value, const Type &new_value)
 Replace each occurrence of one value in a sequence with another value.
template<typename ForwardIterator, typename Predicate, typename Type>
void replace_if (ForwardIterator first, ForwardIterator last, Predicate pred, const Type &new_value)
 Replace each value in a sequence for which a predicate returns true with another value.
template<typename InputIterator, typename OutputIterator, typename Type>
OutputIterator replace_copy (InputIterator first, InputIterator last, OutputIterator __result, const Type &__old_value, const Type &new_value)
 Copy a sequence, replacing each element of one value with another value.
template<typename InputIterator, typename OutputIterator, typename Predicate, typename Type>
OutputIterator replace_copy_if (InputIterator first, InputIterator last, OutputIterator __result, Predicate pred, const Type &new_value)
 Copy a sequence, replacing each value for which a predicate returns true with another value.
template<typename ForwardIterator, typename Generator>
void generate (ForwardIterator first, ForwardIterator last, Generator __gen)
 Assign the result of a function object to each value in a sequence.
template<typename OutputIterator, typename Size, typename Generator>
OutputIterator generate_n (OutputIterator first, Size n, Generator __gen)
 Assign the result of a function object to each value in a sequence.
template<typename InputIterator, typename OutputIterator, typename Type>
OutputIterator remove_copy (InputIterator first, InputIterator last, OutputIterator __result, const Type &value)
 Copy a sequence, removing elements of a given value.
template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator remove_copy_if (InputIterator first, InputIterator last, OutputIterator __result, Predicate pred)
 Copy a sequence, removing elements for which a predicate is true.
template<typename ForwardIterator, typename Type>
ForwardIterator remove (ForwardIterator first, ForwardIterator last, const Type &value)
 Remove elements from a sequence.
template<typename ForwardIterator, typename Predicate>
ForwardIterator remove_if (ForwardIterator first, ForwardIterator last, Predicate pred)
 Remove elements from a sequence using a predicate.
template<typename InputIterator, typename OutputIterator>
OutputIterator unique_copy (InputIterator first, InputIterator last, OutputIterator __result)
 Copy a sequence, removing consecutive duplicate values.
template<typename InputIterator, typename OutputIterator, typename BinaryPredicate>
OutputIterator unique_copy (InputIterator first, InputIterator last, OutputIterator __result, BinaryPredicate __binary_pred)
 Copy a sequence, removing consecutive values using a predicate.
template<typename ForwardIterator>
ForwardIterator unique (ForwardIterator first, ForwardIterator last)
 Remove consecutive duplicate values from a sequence.
template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator unique (ForwardIterator first, ForwardIterator last, BinaryPredicate __binary_pred)
 Remove consecutive values from a sequence using a predicate.
template<typename BidirectionalIterator>
void reverse (BidirectionalIterator first, BidirectionalIterator last)
 Reverse a sequence.
template<typename BidirectionalIterator, typename OutputIterator>
OutputIterator reverse_copy (BidirectionalIterator first, BidirectionalIterator last, OutputIterator __result)
 Copy a sequence, reversing its elements.
template<typename ForwardIterator>
void rotate (ForwardIterator first, ForwardIterator __middle, ForwardIterator last)
 Rotate the elements of a sequence.
template<typename ForwardIterator, typename OutputIterator>
OutputIterator rotate_copy (ForwardIterator first, ForwardIterator __middle, ForwardIterator last, OutputIterator __result)
 Copy a sequence, rotating its elements.
template<typename RandomAccessIterator>
void random_shuffle (RandomAccessIterator first, RandomAccessIterator last)
 Randomly shuffle the elements of a sequence.
template<typename RandomAccessIterator, typename RandomNumberGenerator>
void random_shuffle (RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator &__rand)
 Shuffle the elements of a sequence using a random number generator.
template<typename ForwardIterator, typename Predicate>
ForwardIterator partition (ForwardIterator first, ForwardIterator last, Predicate pred)
 Move elements for which a predicate is true to the beginning of a sequence.
template<typename ForwardIterator, typename Predicate>
ForwardIterator stable_partition (ForwardIterator first, ForwardIterator last, Predicate pred)
 Move elements for which a predicate is true to the beginning of a sequence, preserving relative ordering.
template<typename RandomAccessIterator>
void partial_sort (RandomAccessIterator first, RandomAccessIterator __middle, RandomAccessIterator last)
 Sort the smallest elements of a sequence.
template<typename RandomAccessIterator, typename Compare>
void partial_sort (RandomAccessIterator first, RandomAccessIterator __middle, RandomAccessIterator last, Compare comp)
 Sort the smallest elements of a sequence using a predicate for comparison.
template<typename InputIterator, typename RandomAccessIterator>
RandomAccessIterator partial_sort_copy (InputIterator first, InputIterator last, RandomAccessIterator __result_first, RandomAccessIterator __result_last)
 Copy the smallest elements of a sequence.
template<typename InputIterator, typename RandomAccessIterator, typename Compare>
RandomAccessIterator partial_sort_copy (InputIterator first, InputIterator last, RandomAccessIterator __result_first, RandomAccessIterator __result_last, Compare comp)
 Copy the smallest elements of a sequence using a predicate for comparison.
template<typename RandomAccessIterator>
void sort (RandomAccessIterator first, RandomAccessIterator last)
 Sort the elements of a sequence.
template<typename RandomAccessIterator, typename Compare>
void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
 Sort the elements of a sequence using a predicate for comparison.
template<typename ForwardIterator, typename Type>
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const Type &__val)
 Finds the first position in which val could be inserted without changing the ordering.
template<typename ForwardIterator, typename Type, typename Compare>
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const Type &__val, Compare comp)
 Finds the first position in which val could be inserted without changing the ordering.
template<typename ForwardIterator, typename Type>
ForwardIterator upper_bound (ForwardIterator first, ForwardIterator last, const Type &__val)
 Finds the last position in which val could be inserted without changing the ordering.
template<typename ForwardIterator, typename Type, typename Compare>
ForwardIterator upper_bound (ForwardIterator first, ForwardIterator last, const Type &__val, Compare comp)
 Finds the last position in which val could be inserted without changing the ordering.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator merge (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result)
 Merges two sorted ranges.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Compare>
OutputIterator merge (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result, Compare comp)
 Merges two sorted ranges.
template<typename BidirectionalIterator>
void inplace_merge (BidirectionalIterator first, BidirectionalIterator __middle, BidirectionalIterator last)
 Merges two sorted ranges in place.
template<typename BidirectionalIterator, typename Compare>
void inplace_merge (BidirectionalIterator first, BidirectionalIterator __middle, BidirectionalIterator last, Compare comp)
 Merges two sorted ranges in place.
template<typename RandomAccessIterator>
void stable_sort (RandomAccessIterator first, RandomAccessIterator last)
 Sort the elements of a sequence, preserving the relative order of equivalent elements.
template<typename RandomAccessIterator, typename Compare>
void stable_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
 Sort the elements of a sequence using a predicate for comparison, preserving the relative order of equivalent elements.
template<typename RandomAccessIterator>
void nth_element (RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last)
 Sort a sequence just enough to find a particular position.
template<typename RandomAccessIterator, typename Compare>
void nth_element (RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp)
 Sort a sequence just enough to find a particular position using a predicate for comparison.
template<typename ForwardIterator, typename Type>
pair< ForwardIterator, ForwardIterator > equal_range (ForwardIterator first, ForwardIterator last, const Type &__val)
 Finds the largest subrange in which val could be inserted at any place in it without changing the ordering.
template<typename ForwardIterator, typename Type, typename Compare>
pair< ForwardIterator, ForwardIterator > equal_range (ForwardIterator first, ForwardIterator last, const Type &__val, Compare comp)
 Finds the largest subrange in which val could be inserted at any place in it without changing the ordering.
template<typename ForwardIterator, typename Type>
bool binary_search (ForwardIterator first, ForwardIterator last, const Type &__val)
 Determines whether an element exists in a range.
template<typename ForwardIterator, typename Type, typename Compare>
bool binary_search (ForwardIterator first, ForwardIterator last, const Type &__val, Compare comp)
 Determines whether an element exists in a range.
template<typename InputIterator1, typename InputIterator2>
bool includes (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 Determines whether all elements of a sequence exists in a range.
template<typename InputIterator1, typename InputIterator2, typename Compare>
bool includes (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp)
 Determines whether all elements of a sequence exists in a range using comparison.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator set_union (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result)
 Return the union of two sorted ranges.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Compare>
OutputIterator set_union (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result, Compare comp)
 Return the union of two sorted ranges using a comparison functor.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator set_intersection (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result)
 Return the intersection of two sorted ranges.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Compare>
OutputIterator set_intersection (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result, Compare comp)
 Return the intersection of two sorted ranges using comparison functor.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator set_difference (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result)
 Return the difference of two sorted ranges.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Compare>
OutputIterator set_difference (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result, Compare comp)
 Return the difference of two sorted ranges using comparison functor.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator set_symmetric_difference (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result)
 Return the symmetric difference of two sorted ranges.
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Compare>
OutputIterator set_symmetric_difference (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator __result, Compare comp)
 Return the symmetric difference of two sorted ranges using comparison functor.
template<typename ForwardIterator>
ForwardIterator max_element (ForwardIterator first, ForwardIterator last)
 Return the maximum element in a range.
template<typename ForwardIterator, typename Compare>
ForwardIterator max_element (ForwardIterator first, ForwardIterator last, Compare comp)
 Return the maximum element in a range using comparison functor.
template<typename ForwardIterator>
ForwardIterator min_element (ForwardIterator first, ForwardIterator last)
 Return the minimum element in a range.
template<typename ForwardIterator, typename Compare>
ForwardIterator min_element (ForwardIterator first, ForwardIterator last, Compare comp)
 Return the minimum element in a range using comparison functor.
template<typename BidirectionalIterator>
bool next_permutation (BidirectionalIterator first, BidirectionalIterator last)
 Permute range into the next "dictionary" ordering.
template<typename BidirectionalIterator, typename Compare>
bool next_permutation (BidirectionalIterator first, BidirectionalIterator last, Compare comp)
 Permute range into the next "dictionary" ordering using comparison functor.
template<typename BidirectionalIterator>
bool prev_permutation (BidirectionalIterator first, BidirectionalIterator last)
 Permute range into the previous "dictionary" ordering.
template<typename BidirectionalIterator, typename Compare>
bool prev_permutation (BidirectionalIterator first, BidirectionalIterator last, Compare comp)
 Permute range into the previous "dictionary" ordering using comparison functor.
template<typename InputIterator, typename ForwardIterator>
InputIterator find_first_of (InputIterator first1, InputIterator last1, ForwardIterator first2, ForwardIterator last2)
 Find element from a set in a sequence.
template<typename InputIterator, typename ForwardIterator, typename BinaryPredicate>
InputIterator find_first_of (InputIterator first1, InputIterator last1, ForwardIterator first2, ForwardIterator last2, BinaryPredicate comp)
 Find element from a set in a sequence using a predicate.
template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2)
 Find last matching subsequence in a sequence.
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate comp)
 Find last matching subsequence in a sequence using a predicate.


Detailed Description

This is an internal header file, included by other library headers. You should not attempt to use it directly.

Definition in file stl_algo.h.


Function Documentation

template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator std::adjacent_find ForwardIterator  first,
ForwardIterator  last,
BinaryPredicate  __binary_pred
 

Find two adjacent values in a sequence using a predicate.

Parameters:
first A forward iterator.
last A forward iterator.
binary_pred A binary predicate.
Returns:
The first iterator i such that i and i+1 are both valid iterators in [first,last) and such that binary_pred(*i,*(i+1)) is true, or last if no such iterator exists.

Definition at line 381 of file stl_algo.h.

template<typename ForwardIterator>
ForwardIterator std::adjacent_find ForwardIterator  first,
ForwardIterator  last
 

Find two adjacent values in a sequence that are equal.

Parameters:
first A forward iterator.
last A forward iterator.
Returns:
The first iterator i such that i and i+1 are both valid iterators in [first,last) and such that *i == *(i+1), or last if no such iterator exists.

Definition at line 350 of file stl_algo.h.

Referenced by std::unique().

template<typename InputIterator, typename Type>
iterator_traits<InputIterator>::difference_type std::count InputIterator  first,
InputIterator  last,
const Type &  value
 

Count the number of copies of a value in a sequence.

Parameters:
first An input iterator.
last An input iterator.
value The value to be counted.
Returns:
The number of iterators i in the range [first,last) for which *i == value

Definition at line 412 of file stl_algo.h.

template<typename InputIterator, typename Predicate>
iterator_traits<InputIterator>::difference_type std::count_if InputIterator  first,
InputIterator  last,
Predicate  pred
 

Count the elements of a sequence for which a predicate is true.

Parameters:
first An input iterator.
last An input iterator.
pred A predicate.
Returns:
The number of iterators i in the range [first,last) for which pred(*i) is true.

Definition at line 437 of file stl_algo.h.

template<typename InputIterator, typename Type>
InputIterator std::find InputIterator  first,
InputIterator  last,
const Type &  __val
[inline]
 

Find the first occurrence of a value in a sequence.

Parameters:
first An input iterator.
last An input iterator.
val The value to find.
Returns:
The first iterator i in the range [first,last) such that *i == val, or last if no such iterator exists.

Definition at line 306 of file stl_algo.h.

template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
ForwardIterator1 std::find_end ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator2  last2,
BinaryPredicate  comp
[inline]
 

Find last matching subsequence in a sequence using a predicate.

Parameters:
first1 Start of range to search.
last1 End of range to search.
first2 Start of sequence to match.
last2 End of sequence to match.
comp The predicate to use.
Returns:
The last iterator i in the range [first1,last1-(last2-first2)) such that predicate(*(i+N), (first2+N)) is true for each N in the range [0,last2-first2), or last1 if no such iterator exists.
Searches the range [first1,last1) for a sub-sequence that compares equal value-by-value with the sequence given by [first2,last2) using comp as a predicate and returns an iterator to the first element of the sub-sequence, or last1 if the sub-sequence is not found. The sub-sequence will be the last such subsequence contained in [first,last1).

Because the sub-sequence must lie completely within the range [first1,last1) it must start at a position less than last1-(last2-first2) where last2-first2 is the length of the sub-sequence. This means that the returned iterator i will be in the range [first1,last1-(last2-first2))

Definition at line 5127 of file stl_algo.h.

template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator1 std::find_end ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator2  last2
[inline]
 

Find last matching subsequence in a sequence.

Parameters:
first1 Start of range to search.
last1 End of range to search.
first2 Start of sequence to match.
last2 End of sequence to match.
Returns:
The last iterator i in the range [first1,last1-(last2-first2)) such that *(i+N) == *(first2+N) for each N in the range [0,last2-first2), or last1 if no such iterator exists.
Searches the range [first1,last1) for a sub-sequence that compares equal value-by-value with the sequence given by [first2,last2) and returns an iterator to the first element of the sub-sequence, or last1 if the sub-sequence is not found. The sub-sequence will be the last such subsequence contained in [first,last1).

Because the sub-sequence must lie completely within the range [first1,last1) it must start at a position less than last1-(last2-first2) where last2-first2 is the length of the sub-sequence. This means that the returned iterator i will be in the range [first1,last1-(last2-first2))

Definition at line 5081 of file stl_algo.h.

template<typename InputIterator, typename ForwardIterator, typename BinaryPredicate>
InputIterator std::find_first_of InputIterator  first1,
InputIterator  last1,
ForwardIterator  first2,
ForwardIterator  last2,
BinaryPredicate  comp
 

Find element from a set in a sequence using a predicate.

Parameters:
first1 Start of range to search.
last1 End of range to search.
first2 Start of match candidates.
last2 End of match candidates.
comp Predicate to use.
Returns:
The first iterator i in the range [first1,last1) such that comp(*i, *(i2)) is true and i2 is an interator in [first2,last2), or last1 if no such iterator exists.
Searches the range [first1,last1) for an element that is equal to some element in the range [first2,last2). If found, returns an iterator in the range [first1,last1), otherwise returns last1.

Definition at line 4902 of file stl_algo.h.

template<typename InputIterator, typename ForwardIterator>
InputIterator std::find_first_of InputIterator  first1,
InputIterator  last1,
ForwardIterator  first2,
ForwardIterator  last2
 

Find element from a set in a sequence.

Parameters:
first1 Start of range to search.
last1 End of range to search.
first2 Start of match candidates.
last2 End of match candidates.
Returns:
The first iterator i in the range [first1,last1) such that *i == *(i2) such that i2 is an interator in [first2,last2), or last1 if no such iterator exists.
Searches the range [first1,last1) for an element that is equal to some element in the range [first2,last2). If found, returns an iterator in the range [first1,last1), otherwise returns last1.

Definition at line 4865 of file stl_algo.h.

template<typename InputIterator, typename Predicate>
InputIterator std::find_if InputIterator  first,
InputIterator  last,
Predicate  pred
[inline]
 

Find the first element in a sequence for which a predicate is true.

Parameters:
first An input iterator.
last An input iterator.
pred A predicate.
Returns:
The first iterator i in the range [first,last) such that pred(*i) is true, or last if no such iterator exists.

Definition at line 328 of file stl_algo.h.

template<typename InputIterator, typename Function>
Function std::for_each InputIterator  first,
InputIterator  last,
Function  __f
 

Apply a function to every element of a sequence.

Parameters:
first An input iterator.
last An input iterator.
f A unary function object.
Returns:
f.
Applies the function object f to each element in the range [first,last). f must not modify the order of the sequence. If f has a return value it is ignored.

Definition at line 152 of file stl_algo.h.

template<typename ForwardIterator, typename Generator>
void std::generate ForwardIterator  first,
ForwardIterator  last,
Generator  __gen
 

Assign the result of a function object to each value in a sequence.

Parameters:
first A forward iterator.
last A forward iterator.
gen A function object taking no arguments.
Returns:
generate() returns no value.
Performs the assignment *i = gen() for each i in the range [first,last).

Definition at line 972 of file stl_algo.h.

template<typename OutputIterator, typename Size, typename Generator>
OutputIterator std::generate_n OutputIterator  first,
Size  n,
Generator  __gen
 

Assign the result of a function object to each value in a sequence.

Parameters:
first A forward iterator.
n The length of the sequence.
gen A function object taking no arguments.
Returns:
The end of the sequence, first+n
Performs the assignment *i = gen() for each i in the range [first,first+n).

Definition at line 998 of file stl_algo.h.

template<typename BidirectionalIterator, typename Compare>
void std::inplace_merge BidirectionalIterator  first,
BidirectionalIterator  __middle,
BidirectionalIterator  last,
Compare  comp
 

Merges two sorted ranges in place.

Parameters:
first An iterator.
middle Another iterator.
last Another iterator.
comp A functor to use for comparisons.
Returns:
Nothing.
Merges two sorted and consecutive ranges, [first,middle) and [middle,last), and puts the result in [first,last). The output will be sorted. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.

If enough additional memory is available, this takes (last-first)-1 comparisons. Otherwise an NlogN algorithm is used, where N is distance(first,last).

The comparison function should have the same effects on ordering as the function used for the initial sort.

Definition at line 3491 of file stl_algo.h.

References std::distance().

template<typename BidirectionalIterator>
void std::inplace_merge BidirectionalIterator  first,
BidirectionalIterator  __middle,
BidirectionalIterator  last
 

Merges two sorted ranges in place.

Parameters:
first An iterator.
middle Another iterator.
last Another iterator.
Returns:
Nothing.
Merges two sorted and consecutive ranges, [first,middle) and [middle,last), and puts the result in [first,last). The output will be sorted. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.

If enough additional memory is available, this takes (last-first)-1 comparisons. Otherwise an NlogN algorithm is used, where N is distance(first,last).

Definition at line 3437 of file stl_algo.h.

References std::distance().

template<typename ForwardIterator, typename Compare>
ForwardIterator std::max_element ForwardIterator  first,
ForwardIterator  last,
Compare  comp
 

Return the maximum element in a range using comparison functor.

Parameters:
first Start of range.
last End of range.
comp Comparison functor.
Returns:
Iterator referencing the first instance of the largest value according to comp.

Definition at line 4552 of file stl_algo.h.

template<typename ForwardIterator>
ForwardIterator std::max_element ForwardIterator  first,
ForwardIterator  last
 

Return the maximum element in a range.

Parameters:
first Start of range.
last End of range.
Returns:
Iterator referencing the first instance of the largest value.

Definition at line 4525 of file stl_algo.h.

Referenced by std::valarray< Type >::max().

template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Compare>
OutputIterator std::merge InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2,
OutputIterator  __result,
Compare  comp
 

Merges two sorted ranges.

Parameters:
first1 An iterator.
first2 Another iterator.
last1 Another iterator.
last2 Another iterator.
result An iterator pointing to the end of the merged range.
comp A functor to use for comparisons.
Returns:
An iterator pointing to the first element "not less than" val.
Merges the ranges [first1,last1) and [first2,last2) into the sorted range [result, result + (last1-first1) + (last2-first2)). Both input ranges must be sorted, and the output range must not overlap with either of the input ranges. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.

The comparison function should have the same effects on ordering as the function used for the initial sort.

Definition at line 3018 of file stl_algo.h.

template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator std::merge InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2,
OutputIterator  __result
 

Merges two sorted ranges.

Parameters:
first1 An iterator.
first2 Another iterator.
last1 Another iterator.
last2 Another iterator.
result An iterator pointing to the end of the merged range.
Returns:
An iterator pointing to the first element "not less than" val.
Merges the ranges [first1,last1) and [first2,last2) into the sorted range [result, result + (last1-first1) + (last2-first2)). Both input ranges must be sorted, and the output range must not overlap with either of the input ranges. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.

Definition at line 2960 of file stl_algo.h.

template<typename ForwardIterator, typename Compare>
ForwardIterator std::min_element ForwardIterator  first,
ForwardIterator  last,
Compare  comp
 

Return the minimum element in a range using comparison functor.

Parameters:
first Start of range.
last End of range.
comp Comparison functor.
Returns:
Iterator referencing the first instance of the smallest value according to comp.

Definition at line 4604 of file stl_algo.h.

template<typename ForwardIterator>
ForwardIterator std::min_element ForwardIterator  first,
ForwardIterator  last
 

Return the minimum element in a range.

Parameters:
first Start of range.
last End of range.
Returns:
Iterator referencing the first instance of the smallest value.

Definition at line 4577 of file stl_algo.h.

Referenced by std::valarray< Type >::min().

template<typename BidirectionalIterator, typename Compare>
bool std::next_permutation BidirectionalIterator  first,
BidirectionalIterator  last,
Compare  comp
 

Permute range into the next "dictionary" ordering using comparison functor.

Parameters:
first Start of range.
last End of range.
comp 
Returns:
False if wrapped to first permutation, true otherwise.
Treats all permutations of the range [first,last) as a set of "dictionary" sorted sequences ordered by comp. Permutes the current sequence into the next one of this set. Returns true if there are more sequences to generate. If the sequence is the largest of the set, the smallest is generated and false returned.

Definition at line 4695 of file stl_algo.h.

References std::iter_swap(), and std::reverse().

template<typename BidirectionalIterator>
bool std::next_permutation BidirectionalIterator  first,
BidirectionalIterator  last
 

Permute range into the next "dictionary" ordering.

Parameters:
first Start of range.
last End of range.
Returns:
False if wrapped to first permutation, true otherwise.
Treats all permutations of the range as a set of "dictionary" sorted sequences. Permutes the current sequence into the next one of this set. Returns true if there are more sequences to generate. If the sequence is the largest of the set, the smallest is generated and false returned.

Definition at line 4639 of file stl_algo.h.

References std::iter_swap(), and std::reverse().

template<typename RandomAccessIterator, typename Compare>
void std::nth_element RandomAccessIterator  first,
RandomAccessIterator  nth,
RandomAccessIterator  last,
Compare  comp
 

Sort a sequence just enough to find a particular position using a predicate for comparison.

Parameters:
first An iterator.
nth Another iterator.
last Another iterator.
comp A comparison functor.
Returns:
Nothing.
Rearranges the elements in the range [first,last) so that *nth is the same element that would have been in that position had the whole sequence been sorted. The elements either side of *nth are not completely sorted, but for any iterator in the range [first,nth) and any iterator in the range [nth,last) it holds that comp(*j,*i) is false.

Definition at line 3733 of file stl_algo.h.

References std::__median().

template<typename RandomAccessIterator>
void std::nth_element RandomAccessIterator  first,
RandomAccessIterator  nth,
RandomAccessIterator  last
 

Sort a sequence just enough to find a particular position.

Parameters:
first An iterator.
nth Another iterator.
last Another iterator.
Returns:
Nothing.
Rearranges the elements in the range [first,last) so that *nth is the same element that would have been in that position had the whole sequence been sorted. whole sequence been sorted. The elements either side of *nth are not completely sorted, but for any iterator in the range [first,nth) and any iterator in the range [nth,last) it holds that *j<*i is false.

Definition at line 3682 of file stl_algo.h.

References std::__median().

template<typename RandomAccessIterator, typename Compare>
void std::partial_sort RandomAccessIterator  first,
RandomAccessIterator  __middle,
RandomAccessIterator  last,
Compare  comp
 

Sort the smallest elements of a sequence using a predicate for comparison.

Parameters:
first An iterator.
middle Another iterator.
last Another iterator.
comp A comparison functor.
Returns:
Nothing.
Sorts the smallest (middle-first) elements in the range [first,last) and moves them to the range [first,middle). The order of the remaining elements in the range [middle,last) is undefined. After the sort if i and are iterators in the range [first,middle) such that precedes and is an iterator in the range [middle,last) then *comp(j,*i) and comp(*k,*i) are both false.

Definition at line 2299 of file stl_algo.h.

References std::make_heap(), and std::sort_heap().

template<typename RandomAccessIterator>
void std::partial_sort RandomAccessIterator  first,
RandomAccessIterator  __middle,
RandomAccessIterator  last
 

Sort the smallest elements of a sequence.

Parameters:
first An iterator.
middle Another iterator.
last Another iterator.
Returns:
Nothing.
Sorts the smallest (middle-first) elements in the range [first,last) and moves them to the range [first,middle). The order of the remaining elements in the range [middle,last) is undefined. After the sort if i and are iterators in the range [first,middle) such that precedes and is an iterator in the range [middle,last) then *j<*i and *k<*i are both false.

Definition at line 2258 of file stl_algo.h.

References std::make_heap(), and std::sort_heap().

template<typename InputIterator, typename RandomAccessIterator, typename Compare>
RandomAccessIterator std::partial_sort_copy InputIterator  first,
InputIterator  last,
RandomAccessIterator  __result_first,
RandomAccessIterator  __result_last,
Compare  comp
 

Copy the smallest elements of a sequence using a predicate for comparison.

Parameters:
first An input iterator.
last Another input iterator.
result_first A random-access iterator.
result_last Another random-access iterator.
comp A comparison functor.
Returns:
An iterator indicating the end of the resulting sequence.
Copies and sorts the smallest N values from the range [first,last) to the range beginning at result_first, where the number of elements to be copied, N, is the smaller of (last-first) and (result_last-result_first). After the sort if i and are iterators in the range [result_first,result_first+N) such that precedes then comp(*j,*i) is false. The value returned is result_first+N.

Definition at line 2405 of file stl_algo.h.

References std::make_heap(), and std::sort_heap().

template<typename InputIterator, typename RandomAccessIterator>
RandomAccessIterator std::partial_sort_copy InputIterator  first,
InputIterator  last,
RandomAccessIterator  __result_first,
RandomAccessIterator  __result_last
 

Copy the smallest elements of a sequence.

Parameters:
first An iterator.
last Another iterator.
result_first A random-access iterator.
result_last Another random-access iterator.
Returns:
An iterator indicating the end of the resulting sequence.
Copies and sorts the smallest N values from the range [first,last) to the range beginning at result_first, where the number of elements to be copied, N, is the smaller of (last-first) and (result_last-result_first). After the sort if i and are iterators in the range [result_first,result_first+N) such that precedes then *j<*i is false. The value returned is result_first+N.

Definition at line 2341 of file stl_algo.h.

References std::make_heap(), and std::sort_heap().

template<typename ForwardIterator, typename Predicate>
ForwardIterator std::partition ForwardIterator  first,
ForwardIterator  last,
Predicate  pred
[inline]
 

Move elements for which a predicate is true to the beginning of a sequence.

Parameters:
first A forward iterator.
last A forward iterator.
pred A predicate functor.
Returns:
An iterator middle such that pred(i) is true for each iterator i in the range [first,middle) and false for each i in the range [middle,last).
pred must not modify its operand. partition() does not preserve the relative ordering of elements in each group, use stable_partition() if this is needed.

Definition at line 1858 of file stl_algo.h.

template<typename BidirectionalIterator, typename Compare>
bool std::prev_permutation BidirectionalIterator  first,
BidirectionalIterator  last,
Compare  comp
 

Permute range into the previous "dictionary" ordering using comparison functor.

Parameters:
first Start of range.
last End of range.
comp 
Returns:
False if wrapped to last permutation, true otherwise.
Treats all permutations of the range [first,last) as a set of "dictionary" sorted sequences ordered by comp. Permutes the current sequence into the previous one of this set. Returns true if there are more sequences to generate. If the sequence is the smallest of the set, the largest is generated and false returned.

Definition at line 4806 of file stl_algo.h.

References std::iter_swap(), and std::reverse().

template<typename BidirectionalIterator>
bool std::prev_permutation BidirectionalIterator  first,
BidirectionalIterator  last
 

Permute range into the previous "dictionary" ordering.

Parameters:
first Start of range.
last End of range.
Returns:
False if wrapped to last permutation, true otherwise.
Treats all permutations of the range as a set of "dictionary" sorted sequences. Permutes the current sequence into the previous one of this set. Returns true if there are more sequences to generate. If the sequence is the smallest of the set, the largest is generated and false returned.

Definition at line 4750 of file stl_algo.h.

References std::iter_swap(), and std::reverse().

template<typename RandomAccessIterator, typename RandomNumberGenerator>
void std::random_shuffle RandomAccessIterator  first,
RandomAccessIterator  last,
RandomNumberGenerator &  __rand
 

Shuffle the elements of a sequence using a random number generator.

Parameters:
first A forward iterator.
last A forward iterator.
rand The RNG functor or function.
Returns:
Nothing.
Reorders the elements in the range [first,last) using rand to provide a random distribution. Calling rand(N) for a positive integer N should return a randomly chosen integer from the range [0,N).

Definition at line 1764 of file stl_algo.h.

References std::iter_swap().

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

Randomly shuffle the elements of a sequence.

Parameters:
first A forward iterator.
last A forward iterator.
Returns:
Nothing.
Reorder the elements in the range [first,last) using a random distribution, so that every possible ordering of the sequence is equally likely.

Definition at line 1737 of file stl_algo.h.

References std::iter_swap().

template<typename ForwardIterator, typename Type>
ForwardIterator std::remove ForwardIterator  first,
ForwardIterator  last,
const Type &  value
 

Remove elements from a sequence.

Parameters:
first An input iterator.
last An input iterator.
value The value to be removed.
Returns:
An iterator designating the end of the resulting sequence.
All elements equal to value are removed from the range [first,last).

remove() is stable, so the relative order of elements that are not removed is unchanged.

Elements between the end of the resulting sequence and last are still present, but their value is unspecified.

Definition at line 1100 of file stl_algo.h.

References std::remove_copy().

template<typename InputIterator, typename OutputIterator, typename Type>
OutputIterator std::remove_copy InputIterator  first,
InputIterator  last,
OutputIterator  __result,
const Type &  value
 

Copy a sequence, removing elements of a given value.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
value The value to be removed.
Returns:
An iterator designating the end of the resulting sequence.
Copies each element in the range [first,last) not equal to value to the range beginning at result. remove_copy() is stable, so the relative order of elements that are copied is unchanged.

Definition at line 1025 of file stl_algo.h.

Referenced by std::remove().

template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator std::remove_copy_if InputIterator  first,
InputIterator  last,
OutputIterator  __result,
Predicate  pred
 

Copy a sequence, removing elements for which a predicate is true.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
pred A predicate.
Returns:
An iterator designating the end of the resulting sequence.
Copies each element in the range [first,last) for which pred returns true to the range beginning at result.

remove_copy_if() is stable, so the relative order of elements that are copied is unchanged.

Definition at line 1062 of file stl_algo.h.

Referenced by std::remove_if().

template<typename ForwardIterator, typename Predicate>
ForwardIterator std::remove_if ForwardIterator  first,
ForwardIterator  last,
Predicate  pred
 

Remove elements from a sequence using a predicate.

Parameters:
first A forward iterator.
last A forward iterator.
pred A predicate.
Returns:
An iterator designating the end of the resulting sequence.
All elements for which pred returns true are removed from the range [first,last).

remove_if() is stable, so the relative order of elements that are not removed is unchanged.

Elements between the end of the resulting sequence and last are still present, but their value is unspecified.

Definition at line 1135 of file stl_algo.h.

References std::remove_copy_if().

template<typename ForwardIterator, typename Type>
void std::replace ForwardIterator  first,
ForwardIterator  last,
const Type &  __old_value,
const Type &  new_value
 

Replace each occurrence of one value in a sequence with another value.

Parameters:
first A forward iterator.
last A forward iterator.
old_value The value to be replaced.
new_value The replacement value.
Returns:
replace() returns no value.
For each iterator i in the range [first,last) if *i == old_value then the assignment *i = new_value is performed.

Definition at line 844 of file stl_algo.h.

template<typename InputIterator, typename OutputIterator, typename Type>
OutputIterator std::replace_copy InputIterator  first,
InputIterator  last,
OutputIterator  __result,
const Type &  __old_value,
const Type &  new_value
 

Copy a sequence, replacing each element of one value with another value.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
old_value The value to be replaced.
new_value The replacement value.
Returns:
The end of the output sequence, result+(last-first).
Copies each element in the input range [first,last) to the output range [result,result+(last-first)) replacing elements equal to old_value with new_value.

Definition at line 908 of file stl_algo.h.

template<typename InputIterator, typename OutputIterator, typename Predicate, typename Type>
OutputIterator std::replace_copy_if InputIterator  first,
InputIterator  last,
OutputIterator  __result,
Predicate  pred,
const Type &  new_value
 

Copy a sequence, replacing each value for which a predicate returns true with another value.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
pred A predicate.
new_value The replacement value.
Returns:
The end of the output sequence, result+(last-first).
Copies each element in the range [first,last) to the range [result,result+(last-first)) replacing elements for which pred returns true with new_value.

Definition at line 942 of file stl_algo.h.

template<typename ForwardIterator, typename Predicate, typename Type>
void std::replace_if ForwardIterator  first,
ForwardIterator  last,
Predicate  pred,
const Type &  new_value
 

Replace each value in a sequence for which a predicate returns true with another value.

Parameters:
first A forward iterator.
last A forward iterator.
pred A predicate.
new_value The replacement value.
Returns:
replace_if() returns no value.
For each iterator i in the range [first,last) if pred(*i) is true then the assignment *i = new_value is performed.

Definition at line 875 of file stl_algo.h.

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

Reverse a sequence.

Parameters:
first A bidirectional iterator.
last A bidirectional iterator.
Returns:
reverse() returns no value.
Reverses the order of the elements in the range [first,last), so that the first element becomes the last etc. For every i such that 0<=i<=(last-first)/2), reverse() swaps *(first+i) and *(last-(i+1))

Definition at line 1453 of file stl_algo.h.

Referenced by std::next_permutation(), and std::prev_permutation().

template<typename BidirectionalIterator, typename OutputIterator>
OutputIterator std::reverse_copy BidirectionalIterator  first,
BidirectionalIterator  last,
OutputIterator  __result
 

Copy a sequence, reversing its elements.

Parameters:
first A bidirectional iterator.
last A bidirectional iterator.
result An output iterator.
Returns:
An iterator designating the end of the resulting sequence.
Copies the elements in the range [first,last) to the range [result,result+(last-first)) such that the order of the elements is reversed. For every i such that 0<=i<=(last-first), reverse_copy() performs the assignment *(result+(last-first)-i) = *(first+i). The ranges [first,last) and [result,result+(last-first)) must not overlap.

Definition at line 1479 of file stl_algo.h.

template<typename ForwardIterator>
void std::rotate ForwardIterator  first,
ForwardIterator  __middle,
ForwardIterator  last
[inline]
 

Rotate the elements of a sequence.

Parameters:
first A forward iterator.
middle A forward iterator.
last A forward iterator.
Returns:
Nothing.
Rotates the elements of the range [first,last) by (middle-first) positions so that the element at middle is moved to first, the element at middle+1 is moved to +1 and so on for each element in the range [first,last).

This effectively swaps the ranges [first,middle) and [middle,last).

Performs *(first+(n+(last-middle))%(last-first))=*(first+n) for each n in the range [0,last-first).

Definition at line 1679 of file stl_algo.h.

template<typename ForwardIterator, typename OutputIterator>
OutputIterator std::rotate_copy ForwardIterator  first,
ForwardIterator  __middle,
ForwardIterator  last,
OutputIterator  __result
 

Copy a sequence, rotating its elements.

Parameters:
first A forward iterator.
middle A forward iterator.
last A forward iterator.
result An output iterator.
Returns:
An iterator designating the end of the resulting sequence.
Copies the elements of the range [first,last) to the range beginning at
Returns:
, rotating the copied elements by (middle-first) positions so that the element at middle is moved to result, the element at middle+1 is moved to

+1 and so on for each element in the range [first,last).

Performs *(result+(n+(last-middle))%(last-first))=*(first+n) for each n in the range [0,last-first).

Definition at line 1712 of file stl_algo.h.

template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
ForwardIterator1 std::search ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator2  last2,
BinaryPredicate  predicate
 

Search a sequence for a matching sub-sequence using a predicate.

Parameters:
first1 A forward iterator.
last1 A forward iterator.
first2 A forward iterator.
last2 A forward iterator.
predicate A binary predicate.
Returns:
The first iterator i in the range [first1,last1-(last2-first2)) such that predicate(*(i+N),*(first2+N)) is true for each N in the range [0,last2-first2), or last1 if no such iterator exists.
Searches the range [first1,last1) for a sub-sequence that compares equal value-by-value with the sequence given by [first2,last2), using predicate to determine equality, and returns an iterator to the first element of the sub-sequence, or last1 if no such iterator exists.

See also:
search(ForwardIter1, ForwardIter1, ForwardIter2, ForwardIter2)

Definition at line 548 of file stl_algo.h.

template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator1 std::search ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2,
ForwardIterator2  last2
 

Search a sequence for a matching sub-sequence.

Parameters:
first1 A forward iterator.
last1 A forward iterator.
first2 A forward iterator.
last2 A forward iterator.
Returns:
The first iterator i in the range [first1,last1-(last2-first2)) such that *(i+N) == *(first2+N) for each N in the range [0,last2-first2), or last1 if no such iterator exists.
Searches the range [first1,last1) for a sub-sequence that compares equal value-by-value with the sequence given by [first2,last2) and returns an iterator to the first element of the sub-sequence, or last1 if the sub-sequence is not found.

Because the sub-sequence must lie completely within the range [first1,last1) it must start at a position less than last1-(last2-first2) where last2-first2 is the length of the sub-sequence. This means that the returned iterator i will be in the range [first1,last1-(last2-first2))

Definition at line 476 of file stl_algo.h.

template<typename ForwardIterator, typename Integer, typename Type, typename BinaryPredicate>
ForwardIterator std::search_n ForwardIterator  first,
ForwardIterator  last,
Integer  count,
const Type &  __val,
BinaryPredicate  __binary_pred
 

Search a sequence for a number of consecutive values using a predicate.

Parameters:
first A forward iterator.
last A forward iterator.
count The number of consecutive values.
val The value to find.
binary_pred A binary predicate.
Returns:
The first iterator i in the range [first,last-count) such that binary_pred(*(i+N),val) is true for each N in the range [0,count), or last if no such iterator exists.
Searches the range [first,last) for count consecutive elements for which the predicate returns true.

Definition at line 678 of file stl_algo.h.

template<typename ForwardIterator, typename Integer, typename Type>
ForwardIterator std::search_n ForwardIterator  first,
ForwardIterator  last,
Integer  count,
const Type &  __val
 

Search a sequence for a number of consecutive values.

Parameters:
first A forward iterator.
last A forward iterator.
count The number of consecutive values.
val The value to find.
Returns:
The first iterator i in the range [first,last-count) such that *(i+N) == val for each N in the range [0,count), or last if no such iterator exists.
Searches the range [first,last) for count consecutive elements equal to val.

Definition at line 625 of file stl_algo.h.

template<typename RandomAccessIterator, typename Compare>
void std::sort RandomAccessIterator  first,
RandomAccessIterator  last,
Compare  comp
[inline]
 

Sort the elements of a sequence using a predicate for comparison.

Parameters:
first An iterator.
last Another iterator.
comp A comparison functor.
Returns:
Nothing.
Sorts the elements in the range [first,last) in ascending order, such that comp(*(i+1),*i) is false for every iterator i in the range [first,last-1).

The relative ordering of equivalent elements is not preserved, use stable_sort() if this is needed.

Definition at line 2574 of file stl_algo.h.

template<typename RandomAccessIterator>
void std::sort RandomAccessIterator  first,
RandomAccessIterator  last
[inline]
 

Sort the elements of a sequence.

Parameters:
first An iterator.
last Another iterator.
Returns:
Nothing.
Sorts the elements in the range [first,last) in ascending order, such that *(i+1)<*i is false for each iterator i in the range [first,last-1).

The relative ordering of equivalent elements is not preserved, use stable_sort() if this is needed.

Definition at line 2540 of file stl_algo.h.

template<typename ForwardIterator, typename Predicate>
ForwardIterator std::stable_partition ForwardIterator  first,
ForwardIterator  last,
Predicate  pred
 

Move elements for which a predicate is true to the beginning of a sequence, preserving relative ordering.

Parameters:
first A forward iterator.
last A forward iterator.
pred A predicate functor.
Returns:
An iterator middle such that pred(i) is true for each iterator i in the range [first,middle) and false for each i in the range [middle,last).
Performs the same function as partition() with the additional guarantee that the relative ordering of elements in each group is preserved, so any two elements x and y in the range [first,last) such that pred(x)==pred(y) will have the same relative ordering after calling stable_partition().

Definition at line 1969 of file stl_algo.h.

template<typename RandomAccessIterator, typename Compare>
void std::stable_sort RandomAccessIterator  first,
RandomAccessIterator  last,
Compare  comp
[inline]
 

Sort the elements of a sequence using a predicate for comparison, preserving the relative order of equivalent elements.

Parameters:
first An iterator.
last Another iterator.
comp A comparison functor.
Returns:
Nothing.
Sorts the elements in the range [first,last) in ascending order, such that comp(*(i+1),*i) is false for each iterator i in the range [first,last-1).

The relative ordering of equivalent elements is preserved, so any two elements x and y in the range [first,last) such that comp(x,y) is false and comp(y,x) is false will have the same relative ordering after calling stable_sort().

Definition at line 3641 of file stl_algo.h.

template<typename RandomAccessIterator>
void std::stable_sort RandomAccessIterator  first,
RandomAccessIterator  last
[inline]
 

Sort the elements of a sequence, preserving the relative order of equivalent elements.

Parameters:
first An iterator.
last Another iterator.
Returns:
Nothing.
Sorts the elements in the range [first,last) in ascending order, such that *(i+1)<*i is false for each iterator i in the range [first,last-1).

The relative ordering of equivalent elements is preserved, so any two elements x and y in the range [first,last) such that x<y is false and y<x is false will have the same relative ordering after calling stable_sort().

Definition at line 3600 of file stl_algo.h.

template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator2 std::swap_ranges ForwardIterator1  first1,
ForwardIterator1  last1,
ForwardIterator2  first2
 

Swap the elements of two sequences.

Parameters:
first1 A forward iterator.
last1 A forward iterator.
first2 A forward iterator.
Returns:
An iterator equal to first2+(last1-first1).
Swaps each element in the range [first1,last1) with the corresponding element in the range [first2,(last1-first1)). The ranges must not overlap.

Definition at line 739 of file stl_algo.h.

References std::iter_swap().

template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryOperation>
OutputIterator std::transform InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
OutputIterator  __result,
BinaryOperation  __binary_op
 

Perform an operation on corresponding elements of two sequences.

Parameters:
first1 An input iterator.
last1 An input iterator.
first2 An input iterator.
result An output iterator.
binary_op A binary operator.
Returns:
An output iterator equal to result+(last-first).
Applies the operator to the corresponding elements in the two input ranges and assigns the results to successive elements of the output sequence. Evaluates *(result+N)=binary_op(*(first1+N),*(first2+N)) for each N in the range [0,last1-first1).

binary_op must not alter either of its arguments.

Definition at line 813 of file stl_algo.h.

template<typename InputIterator, typename OutputIterator, typename UnaryOperation>
OutputIterator std::transform InputIterator  first,
InputIterator  last,
OutputIterator  __result,
UnaryOperation  __unary_op
 

Perform an operation on a sequence.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
unary_op A unary operator.
Returns:
An output iterator equal to result+(last-first).
Applies the operator to each element in the input range and assigns the results to successive elements of the output sequence. Evaluates *(result+N)=unary_op(*(first+N)) for each N in the range [0,last-first).

unary_op must not alter its argument.

Definition at line 778 of file stl_algo.h.

template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator std::unique ForwardIterator  first,
ForwardIterator  last,
BinaryPredicate  __binary_pred
 

Remove consecutive values from a sequence using a predicate.

Parameters:
first A forward iterator.
last A forward iterator.
binary_pred A binary predicate.
Returns:
An iterator designating the end of the resulting sequence.
Removes all but the first element from each group of consecutive values for which binary_pred returns true. unique() is stable, so the relative order of elements that are not removed is unchanged. Elements between the end of the resulting sequence and last are still present, but their value is unspecified.

Definition at line 1380 of file stl_algo.h.

References std::adjacent_find().

template<typename ForwardIterator>
ForwardIterator std::unique ForwardIterator  first,
ForwardIterator  last
 

Remove consecutive duplicate values from a sequence.

Parameters:
first A forward iterator.
last A forward iterator.
Returns:
An iterator designating the end of the resulting sequence.
Removes all but the first element from each group of consecutive values that compare equal. unique() is stable, so the relative order of elements that are not removed is unchanged. Elements between the end of the resulting sequence and last are still present, but their value is unspecified.

Definition at line 1341 of file stl_algo.h.

References std::adjacent_find().

template<typename InputIterator, typename OutputIterator, typename BinaryPredicate>
OutputIterator std::unique_copy InputIterator  first,
InputIterator  last,
OutputIterator  __result,
BinaryPredicate  __binary_pred
[inline]
 

Copy a sequence, removing consecutive values using a predicate.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
binary_pred A binary predicate.
Returns:
An iterator designating the end of the resulting sequence.
Copies each element in the range [first,last) to the range beginning at result, except that only the first element is copied from groups of consecutive elements for which binary_pred returns true. unique_copy() is stable, so the relative order of elements that are copied is unchanged.

Definition at line 1308 of file stl_algo.h.

template<typename InputIterator, typename OutputIterator>
OutputIterator std::unique_copy InputIterator  first,
InputIterator  last,
OutputIterator  __result
[inline]
 

Copy a sequence, removing consecutive duplicate values.

Parameters:
first An input iterator.
last An input iterator.
result An output iterator.
Returns:
An iterator designating the end of the resulting sequence.
Copies each element in the range [first,last) to the range beginning at result, except that only the first element is copied from groups of consecutive elements that compare equal. unique_copy() is stable, so the relative order of elements that are copied is unchanged.

Definition at line 1272 of file stl_algo.h.


Generated on Fri May 6 01:11:16 2005 for libstdc++-v3 Source by  doxygen 1.4.2