define whether one element is less than another: the first version compares objects using
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h. This function is an SGI extension; it is not part of the C++ standard.
For the first version:
• The ordering on objects of
For the second version:
Linear. Zero comparisons if
int A[] = {1, 2, 3, 4, 5, 6, 7};
const int N = sizeof(A) / sizeof(int);
assert(!is_heap(A, A+N));
make_heap(A, A+N);
assert(is_heap(A, A+N));
[1] A heap is a particular way of ordering the elements in a range of Random Access Iterators
Minimum and maximum
min
Categories: algorithms, utilities
Component type: function
template <class T>
const T& min(const T& a, const T& b);
template <class T, class BinaryPredicate>
const T& min(const T& a, const T& b, BinaryPredicate comp);
The two versions of
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
For the first version:
For the second version:
const int x = min(3, 9);
assert(x == 3);
max
Categories: algorithms, utilities
Component type: function
template <class T>
const T& max(const T& a, const T& b);
template <class T, class BinaryPredicate>
const T& max(const T& a, const T& b, BinaryPredicate comp);
The two versions of