epoc32/include/stdapis/boost/pending/is_heap.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/pending/is_heap.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,62 @@
     1.4 +//
     1.5 +//=======================================================================
     1.6 +// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
     1.7 +// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
     1.8 +//
     1.9 +// Distributed under the Boost Software License, Version 1.0. (See
    1.10 +// accompanying file LICENSE_1_0.txt or copy at
    1.11 +// http://www.boost.org/LICENSE_1_0.txt)
    1.12 +//=======================================================================
    1.13 +//
    1.14 +#if __KCC
    1.15 +namespace std {
    1.16 +
    1.17 +template <class RandomAccessIterator, class Distance>
    1.18 +bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
    1.19 +               Distance*)
    1.20 +{
    1.21 +  const Distance n = last - first;
    1.22 +
    1.23 +  Distance parent = 0;
    1.24 +  for (Distance child = 1; child < n; ++child) {
    1.25 +    if (first[parent] < first[child]) 
    1.26 +      return false;
    1.27 +    if ((child & 1) == 0)
    1.28 +      ++parent;
    1.29 +  }
    1.30 +  return true;
    1.31 +}
    1.32 +
    1.33 +template <class RandomAccessIterator>
    1.34 +inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last)
    1.35 +{
    1.36 +  return __is_heap(first, last, distance_type(first));
    1.37 +}
    1.38 +
    1.39 +
    1.40 +template <class RandomAccessIterator, class Distance, class StrictWeakOrdering>
    1.41 +bool __is_heap(RandomAccessIterator first, RandomAccessIterator last,
    1.42 +               StrictWeakOrdering comp,
    1.43 +               Distance*)
    1.44 +{
    1.45 +  const Distance n = last - first;
    1.46 +
    1.47 +  Distance parent = 0;
    1.48 +  for (Distance child = 1; child < n; ++child) {
    1.49 +    if (comp(first[parent], first[child]))
    1.50 +      return false;
    1.51 +    if ((child & 1) == 0)
    1.52 +      ++parent;
    1.53 +  }
    1.54 +  return true;
    1.55 +}
    1.56 +
    1.57 +template <class RandomAccessIterator, class StrictWeakOrdering>
    1.58 +inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last,
    1.59 +                    StrictWeakOrdering comp)
    1.60 +{
    1.61 +  return __is_heap(first, last, comp, distance_type(first));
    1.62 +}
    1.63 +
    1.64 +}
    1.65 +#endif