is_heap
Checks if a range is a heap or not
Definition
The is_heap() algorithm is defined in the standard header <algorithm> and in the nonstandard backward-compatibility header <algo.h>.
Interface
#include <algorithm>
template < class RandomAccessIterator >
bool is_heap(
RandomAccessIterator first,
RandomAccessIterator last
);
template < class RandomAccessIterator, class BinaryPredicate >
bool is_heap(
RandomAccessIterator first,
RandomAccessIterator last,
BinaryPredicate comp
);| Parameter | Description |
| first | A random access iterator that indicates the start of a range to check for a heap |
| last | A random access iterator that indicates the end of a range |
| comp | A condition to test to order elements. A binary predicate takes a single argument and returns true or false |
Description
Is_heap function checks if the elements in range [first, last) form a heap.
The first version compares objects using operator< and the second compares objects using a function object comp.
Return Value
Returns true if the elements in the specified range form a heap, otherwise false.
Complexity
The complexity is linear; performs at most (last - first) - 1 comparisons.
References
See Also
- http://www.codecogs.com/reference/computing/stl/algorithms/heap/make_heap.php"make_heap"
- http://www.codecogs.com/reference/computing/stl/algorithms/heap/pop_heap.php"pop_heap"
- http://www.codecogs.com/reference/computing/stl/algorithms/heap/push_heap.php"push_heap"
- http://www.codecogs.com/reference/computing/stl/algorithms/heap/sort_heap.php"sort_heap"