The Standard Template Library provides many types of containers for manipulating values of various types. To make it even more convenient to manipulate the contents of these containers, STL offers a set of generic algorithms that can do everything from locate elements to sort elements into a specified order.

The generic algorithms fall into four categories, as listed here:

  • Non-modifying sequence algorithms: Do not modify the containers on which they work. Such algorithms include
     
    adjacent_find, find, find_end, find_first, count, mismatch, equal, for_each, search.

  • Mutating sequence algorithms: Modify the containers on which they work. Such algorithms include
     
  • copy_backward, fill, generate, partition, random_shuffle, remove, replace, rotate, reverse, swap, swap_ranges, transform, unique.

  • Sorting algorithms: Sort the contents of containers in various ways. These algorithms include
     
  • sort, stable_sort, partial_sort, partial_sort_copy,

    as well as a number of related functions, including
     

    nth_element, binary_search, lower_bound, upper_bound, equal_range, merge, includes, push_heap, pop_heap, make_heap, sort_heap, set_union, set_intersection, set_difference, set_symmetric_difference, min, min_element, max, max_element, lexicographical_compare, next_permutation, prev_permutation.

  • Numeric algorithms: Perform numeric calculations on the contents of containers. These category includes
     
  • accumulate, adjacent_difference, inner_product, iota, partial_sum, power.