Some generic STL Algorithms

Source: Internet
Author: User

Source Address: http://blog.csdn.net/byijie/article/details/8142859

Generic algorithms that I can understand from the materials of Fuzhou University

Algorithm

Min (a, B) returns the minimum value in A and B.

Max (a, B) returns the maximum value in A and B.

Fill (A, A + N, Val) fills the array with Val

Sort (A, A + N, CMP)

Stable_sort (A, A + N, CMP)

List. Sort (CMP) list-based Merge Sorting

Make_heap (A, A + N, CMP) is the largest heap by default, that is, when CMP is true, a performs a leaf.

Pop_heap (A, A + N, CMP) Move the heap top element to a [n-1] And a [0 .. N-2] is still

Push_heap (A, A + N, CMP) adds a [n-1] to heap a [0 .. n-1]

Sort_heap (A, A + N, CMP) converts heap a [n-1] to a [n-1] sorted array.

Lower_bound (A, A + N, Val) returns the first occurrence of the Val position (iterator). If this value is not found, return the confirmation of the number in this array.

Upper_bound (A, A + N, Val) returns the last position (iterator) of the occurrence position)

Max_element (A, A + N, CMP) returns the first occurrence position of the maximum value of the array (iterator)

Min_element (A, A + N, CMP)

Lexicographical_compare (A, A + N, B, B + M, CMP) Compare the sizes in alphabetical order

Swap (a, B) exchange a, B

Copy (A, A + N, B) copy a [0 .. n-1] to B [0 .. n-1]

Swap_ranges (A, A + N, B) exchange a [0... n-1] and B [0... n-1]

Unique_copy (A, A + N, B) removes redundant elements repeated in a [0... n-1] and copies them to B.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.