fix doc example typo
[boost.git] / boost / pending / is_heap.hpp
blobb2e4b00694cf5f0a41ede3e562291d193bfbbfa3
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 //=======================================================================
11 #if __KCC
12 namespace std {
14 template <class RandomAccessIterator, class Distance>
15 bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
16 Distance*)
18 const Distance n = last - first;
20 Distance parent = 0;
21 for (Distance child = 1; child < n; ++child) {
22 if (first[parent] < first[child])
23 return false;
24 if ((child & 1) == 0)
25 ++parent;
27 return true;
30 template <class RandomAccessIterator>
31 inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last)
33 return __is_heap(first, last, distance_type(first));
37 template <class RandomAccessIterator, class Distance, class StrictWeakOrdering>
38 bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
39 StrictWeakOrdering comp,
40 Distance*)
42 const Distance n = last - first;
44 Distance parent = 0;
45 for (Distance child = 1; child < n; ++child) {
46 if (comp(first[parent], first[child]))
47 return false;
48 if ((child & 1) == 0)
49 ++parent;
51 return true;
54 template <class RandomAccessIterator, class StrictWeakOrdering>
55 inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last,
56 StrictWeakOrdering comp)
58 return __is_heap(first, last, comp, distance_type(first));
62 #endif