C++ STL's Algorithms

 

1、adjacent_find:Searches for two adjacent elements that are either equal or satisfy a specified condition.

      A binary predicate takes two arguments and returns truewhen satisfied and false when not satisfied.

2、binary_find:Tests whether there is an element in a sorted range that is equal to a specified value or that is equivalent to it in a sense specified by a binary predicate.

      The sorted range must each be arranged as a precondition to the application of the binary_search algorithm in accordance with the same ordering as is to be used by the algorithm to sort the combined ranges.

3、copy:Assigns the values of elements from a source range to a destination range, iterating through the source sequence of elements and assigning them new positions in a forward direction.

copy can be used to shift elements to the left but not the right, unless there is no overlap between the source and destination ranges. To shift to the right any number of positions, use the copy_backward algorithm.

4、copy_backward:Assigns the values of elements from a source range to a destination range, iterating through the source sequence of elements and assigning them new positions in a backward direction.

copy_backward can be used to shift elements to the right but not the left, unless there is no overlap between the source and destination ranges. To shift to the left any number of positions, use the copy algorithm.

5、count:Returns the number of elements in a range whose values match a specified value.

template<class InputIterator, class Type>
   typename iterator_traits<InputIterator>::difference_type count(
      InputIterator _First, 
      InputIterator _Last, 
      const Type& _Val
   );
6、count_if:Returns the number of elements in a range whose values satisfy a specified condition.

template<class InputIterator, class Predicate>
   typename iterator_traits<InputIterator>::difference_type count_if(
      InputIterator _First, 
      InputIterator _Last,
      Predicate _Pred
   );
7、equal:Compares two ranges element by element either for equality or equivalence in a sense specified by a binary predicate.

template<class InputIterator1, class InputIterator2>
   bool equal(
      InputIterator1 _First1, 
      InputIterator1 _Last1, 
      InputIterator2 _First2
      );
template<class InputIterator1, class InputIterator2, class BinaryPredicate>
   bool equal(
      InputIterator1 _First1, 
      InputIterator1 _Last1, 
      InputIterator2 _First2, 
      BinaryPredicate _Comp
      );
8、equal_range:

Finds a pair of positions in an ordered range, the first less than or equivalent to the position of a specified element and the second greater than the element's position, where the sense of equivalence or ordering used to establish the positions in the sequence may be specified by a binary predicate.

template<class ForwardIterator, class Type>
   pair<ForwardIterator, ForwardIterator> equal_range(
      ForwardIterator _First,
      ForwardIterator _Last, 
      const Type& _Val
   );
template<class ForwardIterator, class Type, class Predicate>
   pair<ForwardIterator, ForwardIterator> equal_range(
      ForwardIterator _First,
      ForwardIterator _Last, 
      const Type& _Val, 
            Predicate _Comp
   );
9、fill:

Assigns the same new value to every element in a specified range.

template<class _FwdIt, class _Ty> inline
    void fill(_FwdIt _First, _FwdIt _Last, const _Ty% _Val);
10、fill_n:Assigns a new value to a specified number of elements in a range beginning with a particular element.

template<class OutputIterator, class Size, class Type>
   void fill_n(
      OutputIterator _First, 
      Size _Count, 
      const Type& _Val
   ); 
11、find:Locates the position of the first occurrence of an element in a range that has a specified value.

template<class InputIterator, class Type>
   InputIterator find(
      InputIterator _First, 
      InputIterator _Last, 
      const Type& _Val
   );
12、find_end:Looks in a range for the last subsequence that is identical to a specified sequence or that is equivalent in a sense specified by a binary predicate.

13、find_first_of:Searches for the first occurrence of any of several values within a target range or for the first occurrence of any of several elements that are equivalent in a sense specified by a binary predicate to a specified set of the elements.

14、find_if:Locates the position of the first occurrence of an element in a range that satisfies a specified condition.

15、for_each:Applies a specified function object to each element in a forward order within a range and returns the function object.

16、generate:Assigns the values generated by a function object to each element in a range.

17、generate_n:Assigns the values generated by a function object to a specified number of element in a range and returns to the position one past the last assigned value.

18、includes:Tests whether one sorted range contains all the elements contained in a second sorted range, where the ordering or equivalence criterion between elements may be specified by a binary predicate.

19、inplace_merge:Combines the elements from two consecutive sorted ranges into a single sorted range, where the ordering criterion may be specified by a binary predicate.

20、inter_swap:Exchanges two values referred to by a pair of specified iterators.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值