The STL algorithm itself is a function template
Getting input data through iterators
Working with data through function objects
Output a result from an iterator
STL algorithms are generic, independent of specific data types, container types
STL Algorithm Classification
Non-variable sequence algorithm
Variable sequence algorithm
Sorting and searching algorithms
Numerical algorithms
Non-variable sequence algorithm
Algorithms that do not directly modify the contents of the container being manipulated
Used to find the specified element, compare two sequences for equality, count elements, etc.
Cases:
Template<class Inputiterator, Class unarypredicate>
Inputiterator find_if (inputiterator First, Inputiterator last, Unarypredicate pred);
Find the first element that pred (x) is true in the [initial, last] interval
Variable sequence algorithm
You can modify the container objects that they manipulate
Algorithms that include copying, deleting, replacing, descending, rotating, swapping, splitting, removing, filling, shuffling, and generating a sequence of sequences
Cases:
Template<class ForwardIterator, Class t>
Inputiterator find_if (forwarditerator first, ForwardIterator last, const t& x);
The elements in the [first, last] interval are all rewritten to X.
Sorting and searching algorithms
To sort a sequence
Merging two ordered sequences
Searching for ordered sequences
Set operations for ordered sequences
Heap algorithm
Cases:
Template <class Randomaccessiterator, class unarypredicate>
void sort (randomaccessiterator first, Randomaccessiterator last, Unarypredicate comp);
Sort the data in the [first, last] interval with the function object comp as "<"
Numerical algorithms
Finding the "and", the "and", the "difference" of the adjacent elements or the inner product of two sequences in the sequence
"+", "Difference" "-" and "+" and "•" of the inner product. Can be specified by a function object
Cases:
Template<class Inputiterator, Class Outputiterator, class binaryfunction>
Outputiterator Partial_sum (inputiterator First, inputiterator last, outputiterator result, binaryfunction op);
For the elements within [first, last], the "and" (so-called parts and ", is a sequence of the same length as the input sequence, whose nth entry is the" and "of the first n elements of the input sequence), with the Function object op as the" + "operator, and the result is output by result, The returned iterator points to the next element of the last element of the output sequence
Part10 generic Programming and C + + Standard Template Library 10.7 algorithm