| Start |
|---|
std::next_permutation Effects: Parameters: Return Value: Complexity: Example: print all the permutation cases of 1,2,3 in lexicographically-increasing order. |
std::for_each Effects: Applies Parameters:
Return value:
Complexity: Applies Example: Applies the given function for every element of the vector |
| std::accumulate Defined in header Effects: std::accumulate (opens new window) performs fold (opens new window) operation using Effectively it's equivalent of: In version (1) Parameters:
Return value: Accumulated value of Complexity: O(n×k), where n is the distance from Example: Simple sum example: Output: Convert digits to number: and later Output: |
std::find Effects Finds the first occurrence of val within the range [first, last) Parameters
Return An iterator that points to the first element within the range that is equal(==) to val, the iterator points to last if val is not found. Example Output |
std::count Effects Counts the number of elements that are equal to val Parameters
Return The number of elements in the range that are equal(==) to val. Example Output |
std::count_if Effects Counts the number of elements in a range for which a specified predicate function is true Parameters
Return The number of elements within the specified range for which the predicate function returned true. Example Output |
std::find_if Effects Finds the first element in a range for which the predicate function Parameters
Return An iterator that points to the first element within the range the predicate function pred returns true for. The iterator points to last if val is not found Example Output |
std::min_element Effects Finds the minimum element in a range Parameters
Return Iterator to the minimum element in the range Complexity Linear in one less than the number of elements compared. Example Output |
| Using std::nth_element To Find The Median (Or Other Quantiles) The Note This function is very efficient - it has linear complexity. For the sake of this example, let's define the median of a sequence of length n as the element that would be in position ⌈n / 2⌉. For example, the median of a sequence of length 5 is the 3rd smallest element, and so is the median of a sequence of length 6. To use this function to find the median, we can use the following. Say we start with To find the pth quantile (opens new window), we would change some of the lines above: and look for the quantile at position |
Read Article
https://develop.horje.com/learn/1434/reference