epoc32/include/stdapis/stlportv5/stl/_heap.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_heap.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,129 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 1994
     1.7 + * Hewlett-Packard Company
     1.8 + *
     1.9 + * Permission to use, copy, modify, distribute and sell this software
    1.10 + * and its documentation for any purpose is hereby granted without fee,
    1.11 + * provided that the above copyright notice appear in all copies and
    1.12 + * that both that copyright notice and this permission notice appear
    1.13 + * in supporting documentation.  Hewlett-Packard Company makes no
    1.14 + * representations about the suitability of this software for any
    1.15 + * purpose.  It is provided "as is" without express or implied warranty.
    1.16 + *
    1.17 + * Copyright (c) 1997
    1.18 + * Silicon Graphics Computer Systems, Inc.
    1.19 + *
    1.20 + * Permission to use, copy, modify, distribute and sell this software
    1.21 + * and its documentation for any purpose is hereby granted without fee,
    1.22 + * provided that the above copyright notice appear in all copies and
    1.23 + * that both that copyright notice and this permission notice appear
    1.24 + * in supporting documentation.  Silicon Graphics makes no
    1.25 + * representations about the suitability of this software for any
    1.26 + * purpose.  It is provided "as is" without express or implied warranty.
    1.27 + */
    1.28 +
    1.29 +/* NOTE: This is an internal header file, included by other STL headers.
    1.30 + *   You should not attempt to use it directly.
    1.31 + */
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_HEAP_H
    1.34 +#define _STLP_INTERNAL_HEAP_H
    1.35 +
    1.36 +#ifndef _STLP_CONFIG_H
    1.37 +#include <stl/_config.h>
    1.38 +#endif
    1.39 +
    1.40 +_STLP_BEGIN_NAMESPACE
    1.41 +
    1.42 +// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
    1.43 +
    1.44 +template <class _RandomAccessIterator>
    1.45 +void 
    1.46 +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
    1.47 +
    1.48 +
    1.49 +template <class _RandomAccessIterator, class _Compare>
    1.50 +void 
    1.51 +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    1.52 +          _Compare __comp);
    1.53 +
    1.54 +template <class _RandomAccessIterator, class _Distance, class _Tp>
    1.55 +void 
    1.56 +__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
    1.57 +              _Distance __len, _Tp __val);
    1.58 +
    1.59 +template <class _RandomAccessIterator, class _Tp, class _Distance>
    1.60 +inline void 
    1.61 +__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    1.62 +           _RandomAccessIterator __result, _Tp __val, _Distance*)
    1.63 +{
    1.64 +  *__result = *__first;
    1.65 +  __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __val);
    1.66 +}
    1.67 +
    1.68 +template <class _RandomAccessIterator>
    1.69 +void pop_heap(_RandomAccessIterator __first, 
    1.70 +	      _RandomAccessIterator __last);
    1.71 +
    1.72 +template <class _RandomAccessIterator, class _Distance,
    1.73 +          class _Tp, class _Compare>
    1.74 +void
    1.75 +__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
    1.76 +              _Distance __len, _Tp __val, _Compare __comp);
    1.77 +
    1.78 +template <class _RandomAccessIterator, class _Tp, class _Compare, 
    1.79 +          class _Distance>
    1.80 +inline void 
    1.81 +__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    1.82 +           _RandomAccessIterator __result, _Tp __val, _Compare __comp,
    1.83 +           _Distance*)
    1.84 +{
    1.85 +  *__result = *__first;
    1.86 +  __adjust_heap(__first, _Distance(0), _Distance(__last - __first), 
    1.87 +                __val, __comp);
    1.88 +}
    1.89 +
    1.90 +template <class _RandomAccessIterator, class _Compare>
    1.91 +void 
    1.92 +pop_heap(_RandomAccessIterator __first,
    1.93 +         _RandomAccessIterator __last, _Compare __comp);
    1.94 +
    1.95 +template <class _RandomAccessIterator>
    1.96 +void 
    1.97 +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
    1.98 +
    1.99 +template <class _RandomAccessIterator, class _Compare>
   1.100 +void 
   1.101 +make_heap(_RandomAccessIterator __first, 
   1.102 +          _RandomAccessIterator __last, _Compare __comp);
   1.103 +
   1.104 +template <class _RandomAccessIterator>
   1.105 +_STLP_INLINE_LOOP
   1.106 +void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
   1.107 +{
   1.108 +  while (__last - __first > 1)
   1.109 +    pop_heap(__first, __last--);
   1.110 +}
   1.111 +
   1.112 +template <class _RandomAccessIterator, class _Compare>
   1.113 +_STLP_INLINE_LOOP
   1.114 +void 
   1.115 +sort_heap(_RandomAccessIterator __first,
   1.116 +          _RandomAccessIterator __last, _Compare __comp)
   1.117 +{
   1.118 +  while (__last - __first > 1)
   1.119 +    pop_heap(__first, __last--, __comp);
   1.120 +}
   1.121 +
   1.122 +_STLP_END_NAMESPACE
   1.123 +
   1.124 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.125 +#  include <stl/_heap.c>
   1.126 +# endif
   1.127 +
   1.128 +#endif /* _STLP_INTERNAL_HEAP_H */
   1.129 +
   1.130 +// Local Variables:
   1.131 +// mode:C++
   1.132 +// End: