Tutorial by Examples

template<class InputIterator, class Function> Function for_each(InputIterator first, InputIterator last, Function f); Effects: Applies f to the result of dereferencing every iterator in the range [first, last) starting from first and proceeding to last - 1. Parameters: first, last -...
template< class Iterator > bool next_permutation( Iterator first, Iterator last ); template< class Iterator, class Compare > bool next_permutation( Iterator first, Iterator last, Compare cmpFun ); Effects: Sift the data sequence of the range [first, last) into the next lexicograph...
Defined in header <numeric> template<class InputIterator, class T> T accumulate(InputIterator first, InputIterator last, T init); // (1) template<class InputIterator, class T, class BinaryOperation> T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation...
template <class InputIterator, class T> InputIterator find (InputIterator first, InputIterator last, const T& val); Effects Finds the first occurrence of val within the range [first, last) Parameters first => iterator pointing to the beginning of the range last => iterator p...
template <class InputIterator, class T> typename iterator_traits<InputIterator>::difference_type count (InputIterator first, InputIterator last, const T& val); Effects Counts the number of elements that are equal to val Parameters first => iterator pointing to the beginnin...
template <class InputIterator, class UnaryPredicate> typename iterator_traits<InputIterator>::difference_type count_if (InputIterator first, InputIterator last, UnaryPredicate red); Effects Counts the number of elements in a range for which a specified predicate function is true P...
template <class InputIterator, class UnaryPredicate> InputIterator find_if (InputIterator first, InputIterator last, UnaryPredicate pred); Effects Finds the first element in a range for which the predicate function pred returns true. Parameters first => iterator pointing to the begin...
template <class ForwardIterator> ForwardIterator min_element (ForwardIterator first, ForwardIterator last); template <class ForwardIterator, class Compare> ForwardIterator min_element (ForwardIterator first, ForwardIterator last,Compare comp); Effects Finds the minimum element i...
The std::nth_element algorithm takes three iterators: an iterator to the beginning, nth position, and end. Once the function returns, the nth element (by order) will be the nth smallest element. (The function has more elaborate overloads, e.g., some taking comparison functors; see the above link for...

Page 1 of 1