 
 
 
|  |  | 
| Category: algorithms | Component type: function | 
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)
                   
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 [f, l). The reason heaps are useful (especially for sorting, or as priority queues) is that they satisfy two important properties. First, *f is the largest element in the heap. Second, it is possible to add an element to a heap (using push_heap), or to remove *f, in logarithmic time. Internally, a heap is a tree represented as a sequential range. The tree is constructed so that that each node is less than or equal to its parent node.
![[Silicon Surf]](http://www.sgi.com/Images/Icon/surf.gif) 
![[STL Home]](stl_home.gif)