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 Single Elements

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

    Find Consecutive Runs of Equal Elements
    Find Subranges

    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,hi,lo) → clamped_value

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

    C++17  clamps value in the interval given by hi and lo; 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

    Random Sampling
    Swapping

    Reordering Elements Reordering Reorder

    Shifting Shift

    Shift Randomly Randomly

    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 / Replacing Values

    Removing Remove

    Sorted Range Operations Sorted Ranges

    Sorted Ranges As Sets

    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


    Beginner's Guide Articles Guide Articles