# stl_algo.h File Reference

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

Go to the source code of this file.

## Namespaces

- namespace std

## Defines

- #define _ALGO_H

## Enumerations

- enum { _S_threshold }
- enum { _S_chunk_size }

## Functions

- template<typename _RandomAccessIterator, typename _Distance, typename _Compare> void __chunk_insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Distance __chunk_size, _Compare __comp)
- template<typename _RandomAccessIterator, typename _Distance> void __chunk_insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Distance __chunk_size)
- template<typename _RandomAccessIterator, typename _Compare> void __final_insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void __final_insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BinaryPredicate> _BidirectionalIterator1 __find_end (_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, bidirectional_iterator_tag, bidirectional_iterator_tag, _BinaryPredicate __comp)
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2> _BidirectionalIterator1 __find_end (_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, bidirectional_iterator_tag, bidirectional_iterator_tag)
- template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> _ForwardIterator1 __find_end (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, forward_iterator_tag, forward_iterator_tag, _BinaryPredicate __comp)
- template<typename _ForwardIterator1, typename _ForwardIterator2> _ForwardIterator1 __find_end (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, forward_iterator_tag, forward_iterator_tag)
- template<typename _EuclideanRingElement> _EuclideanRingElement __gcd (_EuclideanRingElement __m, _EuclideanRingElement __n)
- template<typename _ForwardIterator, typename _Predicate, typename _Distance> _ForwardIterator __inplace_stable_partition (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, _Distance __len)
- template<typename _RandomAccessIterator, typename _Compare> void __inplace_stable_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void __inplace_stable_sort (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _RandomAccessIterator, typename _Compare> void __insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void __insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _RandomAccessIterator, typename _Size, typename _Compare> void __introsort_loop (_RandomAccessIterator __first, _RandomAccessIterator __last, _Size __depth_limit, _Compare __comp)
- template<typename _RandomAccessIterator, typename _Size> void __introsort_loop (_RandomAccessIterator __first, _RandomAccessIterator __last, _Size __depth_limit)
- template<typename _Size> _Size __lg (_Size __n)
- template<typename _Tp, typename _Compare> const _Tp & __median (const _Tp &__a, const _Tp &__b, const _Tp &__c, _Compare __comp)
- template<typename _Tp> const _Tp & __median (const _Tp &__a, const _Tp &__b, const _Tp &__c)
- template<typename _BidirectionalIterator, typename _Distance, typename _Pointer, typename _Compare> void __merge_adaptive (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Pointer __buffer, _Distance __buffer_size, _Compare __comp)
- template<typename _BidirectionalIterator, typename _Distance, typename _Pointer> void __merge_adaptive (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Pointer __buffer, _Distance __buffer_size)
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BidirectionalIterator3, typename _Compare> _BidirectionalIterator3 __merge_backward (_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BidirectionalIterator3 __result, _Compare __comp)
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BidirectionalIterator3> _BidirectionalIterator3 __merge_backward (_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BidirectionalIterator3 __result)
- template<typename _RandomAccessIterator1, typename _RandomAccessIterator2, typename _Distance, typename _Compare> void __merge_sort_loop (_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __result, _Distance __step_size, _Compare __comp)
- template<typename _RandomAccessIterator1, typename _RandomAccessIterator2, typename _Distance> void __merge_sort_loop (_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __result, _Distance __step_size)
- template<typename _RandomAccessIterator, typename _Pointer, typename _Compare> void __merge_sort_with_buffer (_RandomAccessIterator __first, _RandomAccessIterator __last, _Pointer __buffer, _Compare __comp)
- template<typename _RandomAccessIterator, typename _Pointer> void __merge_sort_with_buffer (_RandomAccessIterator __first, _RandomAccessIterator __last, _Pointer __buffer)
- template<typename _BidirectionalIterator, typename _Distance, typename _Compare> void __merge_without_buffer (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Compare __comp)
- template<typename _BidirectionalIterator, typename _Distance> void __merge_without_buffer (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2)
- template<typename _BidirectionalIterator, typename _Predicate> _BidirectionalIterator __partition (_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag)
- template<typename _ForwardIterator, typename _Predicate> _ForwardIterator __partition (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
- template<typename _RandomAccessIterator> void __reverse (_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
- template<typename _BidirectionalIterator> void __reverse (_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
- template<typename _RandomAccessIterator> void __rotate (_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, random_access_iterator_tag)
- template<typename _BidirectionalIterator> void __rotate (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, bidirectional_iterator_tag)
- template<typename _ForwardIterator> void __rotate (_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, forward_iterator_tag)
- template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _Distance> _BidirectionalIterator1 __rotate_adaptive (_BidirectionalIterator1 __first, _BidirectionalIterator1 __middle, _BidirectionalIterator1 __last, _Distance __len1, _Distance __len2, _BidirectionalIterator2 __buffer, _Distance __buffer_size)
- template<typename _ForwardIterator, typename _Pointer, typename _Predicate, typename _Distance> _ForwardIterator __stable_partition_adaptive (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, _Distance __len, _Pointer __buffer, _Distance __buffer_size)
- template<typename _RandomAccessIterator, typename _Pointer, typename _Distance, typename _Compare> void __stable_sort_adaptive (_RandomAccessIterator __first, _RandomAccessIterator __last, _Pointer __buffer, _Distance __buffer_size, _Compare __comp)
- template<typename _RandomAccessIterator, typename _Pointer, typename _Distance> void __stable_sort_adaptive (_RandomAccessIterator __first, _RandomAccessIterator __last, _Pointer __buffer, _Distance __buffer_size)
- template<typename _RandomAccessIterator, typename _Compare> void __unguarded_insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void __unguarded_insertion_sort (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _RandomAccessIterator, typename _Tp, typename _Compare> void __unguarded_linear_insert (_RandomAccessIterator __last, _Tp __val, _Compare __comp)
- template<typename _RandomAccessIterator, typename _Tp> void __unguarded_linear_insert (_RandomAccessIterator __last, _Tp __val)
- template<typename _RandomAccessIterator, typename _Tp, typename _Compare> _RandomAccessIterator __unguarded_partition (_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp __pivot, _Compare __comp)
- template<typename _RandomAccessIterator, typename _Tp> _RandomAccessIterator __unguarded_partition (_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp __pivot)
- template<typename _InputIterator, typename _ForwardIterator, typename _BinaryPredicate> _ForwardIterator __unique_copy (_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __binary_pred, forward_iterator_tag)
- template<typename _InputIterator, typename _OutputIterator, typename _BinaryPredicate> _OutputIterator __unique_copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred, output_iterator_tag)
- template<typename _InputIterator, typename _ForwardIterator> _ForwardIterator __unique_copy (_InputIterator __first, _InputIterator __last, _ForwardIterator __result, forward_iterator_tag)
- template<typename _InputIterator, typename _OutputIterator> _OutputIterator __unique_copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result, output_iterator_tag)
- template<typename _ForwardIterator, typename _BinaryPredicate> _ForwardIterator adjacent_find (_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred)
- template<typename _ForwardIterator> _ForwardIterator adjacent_find (_ForwardIterator __first, _ForwardIterator __last)
- template<typename _ForwardIterator, typename _Tp, typename _Compare> bool binary_search (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val, _Compare __comp)
- template<typename _ForwardIterator, typename _Tp> bool binary_search (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)
- template<typename _InputIterator, typename _Tp> iterator_traits< _InputIterator
  >::difference_type count (_InputIterator __first, _InputIterator __last, const _Tp &__value)
- template<typename _InputIterator, typename _Predicate> iterator_traits< _InputIterator
  >::difference_type count_if (_InputIterator __first, _InputIterator __last, _Predicate __pred)
- template<typename _ForwardIterator, typename _Tp, typename _Compare> pair< _ForwardIterator, _ForwardIterator > equal_range (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val, _Compare __comp)
- template<typename _ForwardIterator, typename _Tp> pair< _ForwardIterator, _ForwardIterator > equal_range (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)
- template<typename _InputIterator, typename _Tp> _InputIterator find (_InputIterator __first, _InputIterator __last, const _Tp &__val)
- template<typename _RandomAccessIterator, typename _Tp> _RandomAccessIterator find (_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp &__val, random_access_iterator_tag)
- template<typename _InputIterator, typename _Tp> _InputIterator find (_InputIterator __first, _InputIterator __last, const _Tp &__val, input_iterator_tag)
- template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> _ForwardIterator1 find_end (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __comp)
- template<typename _ForwardIterator1, typename _ForwardIterator2> _ForwardIterator1 find_end (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2)
- template<typename _InputIterator, typename _ForwardIterator, typename _BinaryPredicate> _InputIterator find_first_of (_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2, _BinaryPredicate __comp)
- template<typename _InputIterator, typename _ForwardIterator> _InputIterator find_first_of (_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2)
- template<typename _InputIterator, typename _Predicate> _InputIterator find_if (_InputIterator __first, _InputIterator __last, _Predicate __pred)
- template<typename _RandomAccessIterator, typename _Predicate> _RandomAccessIterator find_if (_RandomAccessIterator __first, _RandomAccessIterator __last, _Predicate __pred, random_access_iterator_tag)
- template<typename _InputIterator, typename _Predicate> _InputIterator find_if (_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag)
- template<typename _InputIterator, typename _Function> _Function for_each (_InputIterator __first, _InputIterator __last, _Function __f)
- template<typename _ForwardIterator, typename _Generator> void generate (_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
- template<typename _OutputIterator, typename _Size, typename _Generator> _OutputIterator generate_n (_OutputIterator __first, _Size __n, _Generator __gen)
- template<typename _InputIterator1, typename _InputIterator2, typename _Compare> bool includes (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
- template<typename _InputIterator1, typename _InputIterator2> bool includes (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
- template<typename _BidirectionalIterator, typename _Compare> void inplace_merge (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp)
- template<typename _BidirectionalIterator> void inplace_merge (_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
- template<typename _ForwardIterator, typename _Tp, typename _Compare> _ForwardIterator lower_bound (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val, _Compare __comp)
- template<typename _ForwardIterator, typename _Tp> _ForwardIterator lower_bound (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)
- template<typename _ForwardIterator, typename _Compare> _ForwardIterator max_element (_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
- template<typename _ForwardIterator> _ForwardIterator max_element (_ForwardIterator __first, _ForwardIterator __last)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator merge (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> _OutputIterator merge (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
- template<typename _ForwardIterator, typename _Compare> _ForwardIterator min_element (_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
- template<typename _ForwardIterator> _ForwardIterator min_element (_ForwardIterator __first, _ForwardIterator __last)
- template<typename _BidirectionalIterator, typename _Compare> bool next_permutation (_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
- template<typename _BidirectionalIterator> bool next_permutation (_BidirectionalIterator __first, _BidirectionalIterator __last)
- template<typename _RandomAccessIterator, typename _Compare> void nth_element (_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void nth_element (_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)
- template<typename _RandomAccessIterator, typename _Compare> void partial_sort (_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void partial_sort (_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
- template<typename _InputIterator, typename _RandomAccessIterator, typename _Compare> _RandomAccessIterator partial_sort_copy (_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
- template<typename _InputIterator, typename _RandomAccessIterator> _RandomAccessIterator partial_sort_copy (_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
- template<typename _ForwardIterator, typename _Predicate> _ForwardIterator partition (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
- template<typename _BidirectionalIterator, typename _Compare> bool prev_permutation (_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
- template<typename _BidirectionalIterator> bool prev_permutation (_BidirectionalIterator __first, _BidirectionalIterator __last)
- template<typename _RandomAccessIterator, typename _RandomNumberGenerator> void random_shuffle (_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomNumberGenerator &__rand)
- template<typename _RandomAccessIterator> void random_shuffle (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _ForwardIterator, typename _Tp> _ForwardIterator remove (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
- template<typename _InputIterator, typename _OutputIterator, typename _Tp> _OutputIterator remove_copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp &__value)
- template<typename _InputIterator, typename _OutputIterator, typename _Predicate> _OutputIterator remove_copy_if (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
- template<typename _ForwardIterator, typename _Predicate> _ForwardIterator remove_if (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
- template<typename _ForwardIterator, typename _Tp> void replace (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__old_value, const _Tp &__new_value)
- template<typename _InputIterator, typename _OutputIterator, typename _Tp> _OutputIterator replace_copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp &__old_value, const _Tp &__new_value)
- template<typename _InputIterator, typename _OutputIterator, typename _Predicate, typename _Tp> _OutputIterator replace_copy_if (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred, const _Tp &__new_value)
- template<typename _ForwardIterator, typename _Predicate, typename _Tp> void replace_if (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp &__new_value)
- template<typename _BidirectionalIterator> void reverse (_BidirectionalIterator __first, _BidirectionalIterator __last)
- template<typename _BidirectionalIterator, typename _OutputIterator> _OutputIterator reverse_copy (_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
- template<typename _ForwardIterator> void rotate (_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
- template<typename _ForwardIterator, typename _OutputIterator> _OutputIterator rotate_copy (_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
- template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> _ForwardIterator1 search (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __predicate)
- template<typename _ForwardIterator1, typename _ForwardIterator2> _ForwardIterator1 search (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2)
- template<typename _ForwardIterator, typename _Integer, typename _Tp, typename _BinaryPredicate> _ForwardIterator search_n (_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp &__val, _BinaryPredicate __binary_pred)
- template<typename _ForwardIterator, typename _Integer, typename _Tp> _ForwardIterator search_n (_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp &__val)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator set_difference (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> _OutputIterator set_difference (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator set_intersection (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> _OutputIterator set_intersection (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
- 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)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> _OutputIterator set_symmetric_difference (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator set_union (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> _OutputIterator set_union (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
- template<typename _RandomAccessIterator, typename _Compare> void sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void sort (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _ForwardIterator, typename _Predicate> _ForwardIterator stable_partition (_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
- template<typename _RandomAccessIterator, typename _Compare> void stable_sort (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
- template<typename _RandomAccessIterator> void stable_sort (_RandomAccessIterator __first, _RandomAccessIterator __last)
- template<typename _ForwardIterator1, typename _ForwardIterator2> _ForwardIterator2 swap_ranges (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
- template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _BinaryOperation> _OutputIterator transform (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, _BinaryOperation __binary_op)
- template<typename _InputIterator, typename _OutputIterator, typename _UnaryOperation> _OutputIterator transform (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __unary_op)
- template<typename _ForwardIterator, typename _BinaryPredicate> _ForwardIterator unique (_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred)
- template<typename _ForwardIterator> _ForwardIterator unique (_ForwardIterator __first, _ForwardIterator __last)
- template<typename _InputIterator, typename _OutputIterator, typename _BinaryPredicate> _OutputIterator unique_copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred)
- template<typename _InputIterator, typename _OutputIterator> _OutputIterator unique_copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result)
- template<typename _ForwardIterator, typename _Tp, typename _Compare> _ForwardIterator upper_bound (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val, _Compare __comp)
- template<typename _ForwardIterator, typename _Tp> _ForwardIterator upper_bound (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)

## Function Documentation

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

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

iterator_traits<_InputIterator>::difference_type std::count | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | const _Tp & | __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.

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.

_InputIterator std::find | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | const _Tp & | __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.

_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 5144 of file stl_algo.h.

_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 5098 of file stl_algo.h.

_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 4919 of file stl_algo.h.

_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 4882 of file stl_algo.h.

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

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

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.

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

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 3508 of file stl_algo.h.

References std::distance().

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 3454 of file stl_algo.h.

References std::distance().

_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 4569 of file stl_algo.h.

_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 4542 of file stl_algo.h.

Referenced by valarray::max().

_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 3035 of file stl_algo.h.

References std::copy().

_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 2977 of file stl_algo.h.

References std::copy().

_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 4621 of file stl_algo.h.

_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 4594 of file stl_algo.h.

Referenced by valarray::min().

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 4712 of file stl_algo.h.

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

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 4656 of file stl_algo.h.

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

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 3750 of file stl_algo.h.

References std::__median().

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 3699 of file stl_algo.h.

References std::__median().

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 2316 of file stl_algo.h.

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

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 2275 of file stl_algo.h.

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

_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 2422 of file stl_algo.h.

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

_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 2358 of file stl_algo.h.

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

_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 1875 of file stl_algo.h.

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 4823 of file stl_algo.h.

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

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 4767 of file stl_algo.h.

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

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 1781 of file stl_algo.h.

References std::iter_swap().

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 1754 of file stl_algo.h.

References std::iter_swap().

_ForwardIterator std::remove | ( | _ForwardIterator | __first,
|  | _ForwardIterator | __last,
|  | const _Tp & | __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().

_OutputIterator std::remove_copy | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | _OutputIterator | __result,
|  | const _Tp & | __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().

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

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

void std::replace | ( | _ForwardIterator | __first,
|  | _ForwardIterator | __last,
|  | const _Tp & | __old_value,
|  | const _Tp & | __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.

_OutputIterator std::replace_copy | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | _OutputIterator | __result,
|  | const _Tp & | __old_value,
|  | const _Tp & | __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.

_OutputIterator std::replace_copy_if | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | _OutputIterator | __result,
|  | _Predicate | __pred,
|  | const _Tp & | __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.

void std::replace_if | ( | _ForwardIterator | __first,
|  | _ForwardIterator | __last,
|  | _Predicate | __pred,
|  | const _Tp & | __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.

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 1463 of file stl_algo.h.

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

_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 1489 of file stl_algo.h.

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 1696 of file stl_algo.h.

_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 1729 of file stl_algo.h.

References std::copy().

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

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

Referenced by basic_string::find().

_ForwardIterator std::search_n | ( | _ForwardIterator | __first,
|  | _ForwardIterator | __last,
|  | _Integer | __count,
|  | const _Tp & | __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.

_ForwardIterator std::search_n | ( | _ForwardIterator | __first,
|  | _ForwardIterator | __last,
|  | _Integer | __count,
|  | const _Tp & | __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.

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 2591 of file stl_algo.h.

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 2557 of file stl_algo.h.

_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 1986 of file stl_algo.h.

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 3658 of file stl_algo.h.

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 3617 of file stl_algo.h.

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

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

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

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

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

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

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