## is_heap
## Prototype
template <class RandomAccessIterator> bool is_heap(RandomAccessIterator first, RandomAccessIterator last); template <class RandomAccessIterator, class StrictWeakOrdering> inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp) ## Description
## DefinitionDefined 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. ## Requirements on typesFor the first version: -
`RandomAccessIterator` is a model of RandomAccessIterator. -
`RandomAccessIterator` 's value type is a model of LessThanComparable. -
The ordering on objects of
`RandomAccessIterator` 's value type is a*strict weak ordering*, as defined in the LessThanComparable requirements.
For the second version: -
`RandomAccessIterator` is a model of RandomAccessIterator. -
`StrictWeakOrdering` is a model of StrictWeakOrdering. -
`RandomAccessIterator` 's value type is convertible to`StrictWeakOrdering` 's argument type.
## Preconditions-
`[first, last)` is a valid range.
## ComplexityLinear. Zero comparisons if ## Exampleint 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)); ## Notes[1] A heap is a particular way of ordering the elements in a range of RandomAccessIterator ## See also |