previous |
start
Standard Algorithms
- The standard library provides a wealth of
ready-to-use and fully debugged data structures and
algorithms.
- for_each applies a function to each
element
- find (as above)
- find_if locates the first element
fulfilling a condition
- count (as above)
- equal tests if containers have the
same elements in the same order
- replace/replace_if replace
all matching elements with a new one
- unique remove adjacent identical
values
- min_element, max_element
finds the smallest and largest elements
- next_permutation rearranges the
elements; call it n! times iterates through all
permutations
- sort sorts the elements;
stable_sort performs better if the container is already
almost sorted
- random_shuffle randomly rearranges the
elements
- nth_element find the nth
element without sorting the container.
- plus many more...
- Before writing a lot of code from scratch,
check whether the standard library already has what you
need.
previous |
start