epoc32/include/stdapis/stlport/stl/_heap.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  *
     3  * Copyright (c) 1994
     4  * Hewlett-Packard Company
     5  *
     6  * Permission to use, copy, modify, distribute and sell this software
     7  * and its documentation for any purpose is hereby granted without fee,
     8  * provided that the above copyright notice appear in all copies and
     9  * that both that copyright notice and this permission notice appear
    10  * in supporting documentation.  Hewlett-Packard Company makes no
    11  * representations about the suitability of this software for any
    12  * purpose.  It is provided "as is" without express or implied warranty.
    13  *
    14  * Copyright (c) 1997
    15  * Silicon Graphics Computer Systems, Inc.
    16  *
    17  * Permission to use, copy, modify, distribute and sell this software
    18  * and its documentation for any purpose is hereby granted without fee,
    19  * provided that the above copyright notice appear in all copies and
    20  * that both that copyright notice and this permission notice appear
    21  * in supporting documentation.  Silicon Graphics makes no
    22  * representations about the suitability of this software for any
    23  * purpose.  It is provided "as is" without express or implied warranty.
    24  */
    25 
    26 /* NOTE: This is an internal header file, included by other STL headers.
    27  *   You should not attempt to use it directly.
    28  */
    29 
    30 #ifndef _STLP_INTERNAL_HEAP_H
    31 #define _STLP_INTERNAL_HEAP_H
    32 
    33 #ifndef _STLP_CONFIG_H
    34 #include <stl/_config.h>
    35 #endif
    36 
    37 _STLP_BEGIN_NAMESPACE
    38 
    39 // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
    40 
    41 template <class _RandomAccessIterator>
    42 void 
    43 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
    44 
    45 
    46 template <class _RandomAccessIterator, class _Compare>
    47 void 
    48 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    49           _Compare __comp);
    50 
    51 template <class _RandomAccessIterator, class _Distance, class _Tp>
    52 void 
    53 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
    54               _Distance __len, _Tp __val);
    55 
    56 template <class _RandomAccessIterator, class _Tp, class _Distance>
    57 inline void 
    58 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    59            _RandomAccessIterator __result, _Tp __val, _Distance*)
    60 {
    61   *__result = *__first;
    62   __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __val);
    63 }
    64 
    65 template <class _RandomAccessIterator>
    66 void pop_heap(_RandomAccessIterator __first, 
    67 	      _RandomAccessIterator __last);
    68 
    69 template <class _RandomAccessIterator, class _Distance,
    70           class _Tp, class _Compare>
    71 void
    72 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
    73               _Distance __len, _Tp __val, _Compare __comp);
    74 
    75 template <class _RandomAccessIterator, class _Tp, class _Compare, 
    76           class _Distance>
    77 inline void 
    78 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    79            _RandomAccessIterator __result, _Tp __val, _Compare __comp,
    80            _Distance*)
    81 {
    82   *__result = *__first;
    83   __adjust_heap(__first, _Distance(0), _Distance(__last - __first), 
    84                 __val, __comp);
    85 }
    86 
    87 template <class _RandomAccessIterator, class _Compare>
    88 void 
    89 pop_heap(_RandomAccessIterator __first,
    90          _RandomAccessIterator __last, _Compare __comp);
    91 
    92 template <class _RandomAccessIterator>
    93 void 
    94 make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
    95 
    96 template <class _RandomAccessIterator, class _Compare>
    97 void 
    98 make_heap(_RandomAccessIterator __first, 
    99           _RandomAccessIterator __last, _Compare __comp);
   100 
   101 template <class _RandomAccessIterator>
   102 _STLP_INLINE_LOOP
   103 void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
   104 {
   105   while (__last - __first > 1)
   106     pop_heap(__first, __last--);
   107 }
   108 
   109 template <class _RandomAccessIterator, class _Compare>
   110 _STLP_INLINE_LOOP
   111 void 
   112 sort_heap(_RandomAccessIterator __first,
   113           _RandomAccessIterator __last, _Compare __comp)
   114 {
   115   while (__last - __first > 1)
   116     pop_heap(__first, __last--, __comp);
   117 }
   118 
   119 _STLP_END_NAMESPACE
   120 
   121 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
   122 #  include <stl/_heap.c>
   123 # endif
   124 
   125 #endif /* _STLP_INTERNAL_HEAP_H */
   126 
   127 // Local Variables:
   128 // mode:C++
   129 // End: