A brief introduction to the common functions in header algorithm

  • 2020-05-24 05:51:17
  • OfStack

1. Non-modifiable sequence operations (12)

The loop performs an operation on each element in the sequence. for_each()

Find the first occurrence of a value in a sequence. find()

Find the first element in the sequence that matches a predicate find_if()

Find the position of the last occurrence of 1 sub-sequence in the sequence find_end()

Find the position in the sequence where the value in the specified set occurs for the first time. find_first_of()

Find the adjacent 1 pair adjacent_find() in the sequence

Count the number of times a value occurs in a sequence. count()

Count the number of matches with a predicate in the sequence count_if()

Compare and find the first element that is different from the two sequences mismatch()

The corresponding elements in both sequences are the same and are true equal()

Search to find the location of the first occurrence of the 1 sub-sequence in the sequence. search()

Find the location of the continuous n occurrence of 1 value in the sequence. search_n()

2. Modified sequence operation (27)

Copy starts at the first element of the sequence. copy()

Copy from the last element of the sequence copy_backward()

Swap swap two elements swap()

Swap the element swap_ranges() for the specified range

Swap the two elements referred to by the iterator iter_swap()

The transform applies an operation to each element of the specified range, transform()

I'm going to replace 1 of the values with a given value, replace()

Replace some elements that satisfy the predicate replace_if()

Replace the element replace_copy() with a given value of 1 when copying a sequence

Replace the element that satisfies the predicate when replicating the sequence replace_copy_if()

Fill replace all elements with 1 given value fill()

Replace the previous n elements with 1 given value fill_n()

Generate replace all elements generate() with the result of the 1 operation

Replace the previous n elements generate_n() with the result of the 1 operation

Delete delete the element remove() with the given value

Delete the element remove_if() that satisfies the predicate

Delete the element remove_copy() with the given value when copying the sequence

When copying a sequence, delete the element that satisfies the predicate remove_copy_if()

Delete the adjacent duplicate element unique()

Delete adjacent duplicate elements unique_copy()

Reverse the order of reversing elements reverse()

Reverse the order of the elements when copying a sequence.

Circular move circular move element rotate()

Loop moves element rotate_copy() while copying sequence

Random element random_shuffle()

Partition puts all the elements that satisfy a predicate in front of partition()

Put all the elements that satisfy a predicate first and keep the order stable_partition()

3. Sequence sequencing and related operations (27)

Sort with good average efficiency

Sort and maintain the original order of the same elements. stable_sort()

Order the first part of the sequence partial_sort()

Order the first part of the sequence as you copy. partial_sort_copy()

n element put each element of n in its correct position. nth_element()

2 points search for the first occurrence of a value greater than or equal to lower_bound()

Find the first occurrence of a value greater than upper_bound()

Find the maximum range of values that can be inserted into a given value (without breaking the order).

Determine whether a given element exists in an ordered sequence binary_search()

Merge merge two ordered sequences merge()

Merge two sequential sequences inplace_merge()

Set operation on an ordered structure is true when sequence 1 is a subsequence of another sequence 1 ()

Construct an ordered union of two sets set_union()

Construct an ordered intersection of two sets set_intersection()

Construct the ordered difference set set_difference() of two sets

Construct the ordered symmetry difference set (union - intersection) of two sets set_symmetric_difference()

Heap operation adds the element push_heap() to the heap

Eject the element pop_heap() from the heap

Construct heap make_heap() from sequence

Sort the heap sort_heap()

min() the smaller of the maximum and minimum values

The larger of the two values is max()

The smallest element in the sequence min_element()

The largest element in the sequence max_element()

The dictionary compares two sequences with the first in lexicographically order before lexicographical_compare()

Arrange the generator in lexicographically order the next order nex

rmutation()

prev_permutation()


Related articles: