Node:Minimum and maximum, Next:, Previous:Heap operations, Up:Sorting and related operations



Minimum and maximum

const T& min (const T& a, const T& b) Function
const T& min (const T& a, const T& b, Compare comp) Function
const T& max (const T& a, const T& b) Function
const T& max (const T& a, const T& b, Compare comp) Function

template  const T& min(const T& a, const T& b);

template 
const T& min(const T& a, const T& b, Compare comp);

template  const T& max(const T& a, const T& b);

template 
const T& max(const T& a, const T& b, Compare comp);

min returns the smaller and max the larger. min and max return the first argument when their arguments are equal.

ForwardIterator max_element (ForwardIterator first, ForwardIterator last) Function
ForwardIterator max_element (ForwardIterator first, ForwardIterator last, Compare comp) Function

template 
ForwardIterator max_element(ForwardIterator first, ForwardIterator last);

template 
ForwardIterator max_element(ForwardIterator first, ForwardIterator last,
                            Compare comp);

max_element returns the first iterator i in the range [first, last) such that for any iterator j in the range [first, last) the following corresponding conditions hold: !(*i < *j) or comp(*i, *j) == false. Exactly max((last - first) - 1, 0) applications of the corresponding comparisons are done.

ForwardIterator min_element (ForwardIterator first, ForwardIterator last) Function
ForwardIterator min_element (ForwardIterator first, ForwardIterator last, Compare comp) Function

template 
ForwardIterator min_element(ForwardIterator first, ForwardIterator last);

template 
ForwardIterator min_element(ForwardIterator first, ForwardIterator last,
                            Compare comp);

min_element returns the first iterator i in the range [first, last) such that for any iterator j in the range [first, last) the following corresponding conditions hold: !(*j < *i) or comp(*j, *i) == false. Exactly max((last - first) - 1, 0) applications of the corresponding comparisons are done.