C++ 標準庫之algorithm

來源:互聯網
上載者:User
The header <algorithm>

defines a collection of functions especially designed to be used on ranges of elements.

A range is any sequence of objects that can be accessed through
iterators or pointers, such as an array or an instance of some of the STL containers

.
Notice though, that algorithms operate through iterators directly on
the values, not affecting in any way the structure of any possible
container (it never affects the size or storage allocation of the
container).

Functions in <algorithm>

Non-modifying sequence operations

:

for_each

Apply function to range (template function)

find

Find value in range (function template)

find_if

Find element in range (function template)

find_end

Find last subsequence in range (function template)

find_first_of

Find element from set in range (function template)

adjacent_find

Find equal adjacent elements in range (function template)

count

Count appearances of value in range (function template)

count_if

Return number of elements in range satisfying condition (function template)

mismatch

Return first position where two ranges differ (function template)

equal

Test whether the elements in two ranges are equal (function template)

search

Find subsequence in range (function template)

search_n

Find succession of equal values in range (function template)

Modifying sequence operations

:

copy

Copy range of elements (function template)

copy_backward

Copy range of elements backwards (function template)

swap

Exchange values of two objects (function template)

swap_ranges

Exchange values of two ranges (function template)

iter_swap

Exchange values of objects pointed by two iterators (function template)

transform

Apply function to range (function template)

replace

Replace value in range (function template)

replace_if

Replace values in range (function template)

replace_copy

Copy range replacing value (function template)

replace_copy_if

Copy range replacing value (function template)

fill

Fill range with value (function template)

fill_n

Fill sequence with value (function template)

generate

Generate values for range with function (function template)

generate_n

Generate values for sequence with function (function template)

remove

Remove value from range (function template)

remove_if

Remove elements from range (function template)

remove_copy

Copy range removing value (function template)

remove_copy_if

Copy range removing values (function template)

unique

Remove consecutive duplicates in range (function template)

unique_copy

Copy range removing duplicates (function template)

reverse

Reverse range (function template)

reverse_copy

Copy range reversed (function template)

rotate

Rotate elements in range (function template)

rotate_copy

Copy rotated range (function template)

random_shuffle

Rearrange elements in range randomly (function template)

partition

Partition range in two (function template)

stable_partition

Partition range in two - stable ordering (function template)

Sorting

:

sort

Sort elements in range (function template)

stable_sort

Sort elements preserving order of equivalents (function template)

partial_sort

Partially Sort elements in range (function template)

partial_sort_copy

Copy and partially sort range (function template)

nth_element

Sort element in range (function template)

Binary search

(operating on sorted ranges):

lower_bound

Return iterator to lower bound (function template)

upper_bound

Return iterator to upper bound (function template)

equal_range

Get subrange of equal elements (function template)

binary_search

Test if value exists in sorted array (function template)

Merge

(operating on sorted ranges):

merge

Merge sorted ranges (function template)

inplace_merge

Merge consecutive sorted ranges (function template)

includes

Test whether sorted range includes another sorted range (function template)

set_union

Union of two sorted ranges (function template)

set_intersection

Intersection of two sorted ranges (function template)

set_difference

Difference of two sorted ranges (function template)

set_symmetric_difference

Symmetric difference of two sorted ranges (function template)

Heap

:

push_heap

Push element into heap range (function template)

pop_heap

Pop element from heap range (function template)

make_heap

Make heap from range (function template)

sort_heap

Sort elements of heap (function template)

Min/max

:

min

Return the lesser of two arguments (function template)

max

Return the greater of two arguments (function template)

min_element

Return smallest element in range (function template)

max_element

Return largest element in range (function template)

lexicographical_compare

Lexicographical less-than comparison (function template)

next_permutation

Transform range to next permutation (function template)

prev_permutation

Transform range to previous permutation (function template)

具體的函數就不翻譯了,個人英文水平不高,呵呵。不懂的單詞http://translate.google.cn
翻譯一下。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.