# Standard Library AlgorithmsStandard AlgorithmsAlgorithms

C++20 variants taking single range object as inputs

## Non-Modifying OperationsNon-ModifyingNon-Mod.

### Finding / Locating ElementsLocate

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

### Minimum / MaximumMin/Max

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

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

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

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

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

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

``` minmax(a, b) → ``` { smallest , largest }

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

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

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

``` clamp(value, lo, hi) → clamped_value```

``` clamp(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<`

## Reordering ElementsReorderingReorder

### Heap OperationsHeaps

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

## Numeric OperationsNumeric OperationsNumeric

### ReductionsReduce

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`