2
//=======================================================================
3
// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
4
// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
6
// This file is part of the Generic Graph Component Library
8
// You should have received a copy of the License Agreement for the
9
// Generic Graph Component Library along with the software; see the
10
// file LICENSE. If not, contact Office of Research, University of Notre
11
// Dame, Notre Dame, IN 46556.
13
// Permission to modify the code and to distribute modified code is
14
// granted, provided the text of this NOTICE is retained, a notice that
15
// the code was modified is included with the above COPYRIGHT NOTICE and
16
// with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE
17
// file is distributed with the modified code.
19
// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
20
// By way of example, but not limitation, Licensor MAKES NO
21
// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
22
// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
23
// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
25
//=======================================================================
30
template <class RandomAccessIterator, class Distance>
31
bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
34
const Distance n = last - first;
37
for (Distance child = 1; child < n; ++child) {
38
if (first[parent] < first[child])
46
template <class RandomAccessIterator>
47
inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last)
49
return __is_heap(first, last, distance_type(first));
53
template <class RandomAccessIterator, class Distance, class StrictWeakOrdering>
54
bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
55
StrictWeakOrdering comp,
58
const Distance n = last - first;
61
for (Distance child = 1; child < n; ++child) {
62
if (comp(first[parent], first[child]))
70
template <class RandomAccessIterator, class StrictWeakOrdering>
71
inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last,
72
StrictWeakOrdering comp)
74
return __is_heap(first, last, comp, distance_type(first));