• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //=======================================================================
3 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
5 //
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //=======================================================================
10 //
11 #if __KCC
12 namespace std
13 {
14 
15 template < class RandomAccessIterator, class Distance >
__is_heap(RandomAccessIterator first,RandomAccessIterator last,Distance *)16 bool __is_heap(RandomAccessIterator first, RandomAccessIterator last, Distance*)
17 {
18     const Distance n = last - first;
19 
20     Distance parent = 0;
21     for (Distance child = 1; child < n; ++child)
22     {
23         if (first[parent] < first[child])
24             return false;
25         if ((child & 1) == 0)
26             ++parent;
27     }
28     return true;
29 }
30 
31 template < class RandomAccessIterator >
is_heap(RandomAccessIterator first,RandomAccessIterator last)32 inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last)
33 {
34     return __is_heap(first, last, distance_type(first));
35 }
36 
37 template < class RandomAccessIterator, class Distance,
38     class StrictWeakOrdering >
__is_heap(RandomAccessIterator first,RandomAccessIterator last,StrictWeakOrdering comp,Distance *)39 bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
40     StrictWeakOrdering comp, Distance*)
41 {
42     const Distance n = last - first;
43 
44     Distance parent = 0;
45     for (Distance child = 1; child < n; ++child)
46     {
47         if (comp(first[parent], first[child]))
48             return false;
49         if ((child & 1) == 0)
50             ++parent;
51     }
52     return true;
53 }
54 
55 template < class RandomAccessIterator, class StrictWeakOrdering >
is_heap(RandomAccessIterator first,RandomAccessIterator last,StrictWeakOrdering comp)56 inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last,
57     StrictWeakOrdering comp)
58 {
59     return __is_heap(first, last, comp, distance_type(first));
60 }
61 
62 }
63 #endif
64