Contents A-Z
    A-B
    C
    D-E
    F
    G-H
    I
    L
    M
    N
    P
    R
    S
    T
    U-Z

    Standard Library Algorithms Standard Algorithms Algorithms

    C++20 variants taking single range object as inputs

    Non-Modifying Operations Non-Modifying Non-Mod.

    Existence Queries Existence

    Finding / Locating Elements Locate

    find the 1st matching position in range s of any element contained in range w

    Comparing Ranges Compare

    Binary Search of Sorted Ranges Binary Search Binary Search

    Minimum / Maximum Min/Max

    (a, b) →  a if (a < b) is true, b otherwise

    (a, b, f(o,o)→bool) →  a if f(a,b) is true, b otherwise

    ({v1,v2,v3, …}) →  smallest value C++11


    (a, b) →  b if (a < b) is true, a otherwise

    (a, b, f(o,o)→bool) →  b if f(a,b) is true, a otherwise

    ({v1,v2,v3,…}) →  largest value C++11


    (a, b) →  { smallest , largest }

    (a, b, f(o,o)→bool) →  { smallest , largest }

    ({v1,v2,v3, …}) →  { smallest , largest }

    C++11  custom comparison function/object: f(a,b) must return true if a should be ordered before b


    (value, lo, hi) → clamped_value

    (value, lo, hi, f(o,o)→bool) → clamped_value

    C++17  clamps value in the interval given by lo and hi; the second version uses f to compare values instead of operator<

    Structural Properties Structural

    Traversing Ranges Traversal

    Copying / Moving / Swapping Elements Copy/Move/Swap Copy/Move

    Reordering Elements Reordering Reorder

    Shifting Shift

    Sorting Sort

    Partitioning Partition

    Permutations Permute

    Heap Operations Heaps

    for using contiguous containers (std::array, std::vector, …) as a max heap, i.e., a (conceptual) binary tree where each parent has a larger value than its children

    learn more…

    Modifying Elements Modify

    Changing Values

    Replacing Values Replace

    Removing Remove

    Sorted Range Operations Sorted Ranges

    Numeric Operations Numeric Operations Numeric

    Reductions Reduce

    prefer C++17's reduce over accumulate

    prefer C++17's transform_reduce over inner_product

    Scans (Prefix Sums) Scan

    prefer C++17's inclusive_scan over partial_sum

    Range & Iterator Utilities Range Utilities Utilities


    legend of symbols and colors used in algorithm visualizations

    Beginner's Guide Articles Guide Articles