_heap.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Permission to use, copy, modify, distribute and sell this software
00007  * and its documentation for any purpose is hereby granted without fee,
00008  * provided that the above copyright notice appear in all copies and
00009  * that both that copyright notice and this permission notice appear
00010  * in supporting documentation.  Hewlett-Packard Company makes no
00011  * representations about the suitability of this software for any
00012  * purpose.  It is provided "as is" without express or implied warranty.
00013  *
00014  * Copyright (c) 1997
00015  * Silicon Graphics Computer Systems, Inc.
00016  *
00017  * Permission to use, copy, modify, distribute and sell this software
00018  * and its documentation for any purpose is hereby granted without fee,
00019  * provided that the above copyright notice appear in all copies and
00020  * that both that copyright notice and this permission notice appear
00021  * in supporting documentation.  Silicon Graphics makes no
00022  * representations about the suitability of this software for any
00023  * purpose.  It is provided "as is" without express or implied warranty.
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_HEAP_H
00031 #define _STLP_INTERNAL_HEAP_H
00032 
00033 #ifndef _STLP_CONFIG_H
00034 #include <stl/_config.h>
00035 #endif
00036 
00037 _STLP_BEGIN_NAMESPACE
00038 
00039 // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
00040 
00041 template <class _RandomAccessIterator>
00042 void 
00043 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
00044 
00045 
00046 template <class _RandomAccessIterator, class _Compare>
00047 void 
00048 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00049           _Compare __comp);
00050 
00051 template <class _RandomAccessIterator, class _Distance, class _Tp>
00052 void 
00053 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
00054               _Distance __len, _Tp __value);
00055 
00056 template <class _RandomAccessIterator, class _Tp, class _Distance>
00057 inline void 
00058 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00059            _RandomAccessIterator __result, _Tp __value, _Distance*)
00060 {
00061   *__result = *__first;
00062   __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);
00063 }
00064 
00065 template <class _RandomAccessIterator>
00066 void pop_heap(_RandomAccessIterator __first, 
00067               _RandomAccessIterator __last);
00068 
00069 template <class _RandomAccessIterator, class _Distance,
00070           class _Tp, class _Compare>
00071 void
00072 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
00073               _Distance __len, _Tp __value, _Compare __comp);
00074 
00075 template <class _RandomAccessIterator, class _Tp, class _Compare, 
00076           class _Distance>
00077 inline void 
00078 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00079            _RandomAccessIterator __result, _Tp __value, _Compare __comp,
00080            _Distance*)
00081 {
00082   *__result = *__first;
00083   __adjust_heap(__first, _Distance(0), _Distance(__last - __first), 
00084                 __value, __comp);
00085 }
00086 
00087 template <class _RandomAccessIterator, class _Compare>
00088 void 
00089 pop_heap(_RandomAccessIterator __first,
00090          _RandomAccessIterator __last, _Compare __comp);
00091 
00092 template <class _RandomAccessIterator>
00093 void 
00094 make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
00095 
00096 template <class _RandomAccessIterator, class _Compare>
00097 void 
00098 make_heap(_RandomAccessIterator __first, 
00099           _RandomAccessIterator __last, _Compare __comp);
00100 
00101 template <class _RandomAccessIterator>
00102 _STLP_INLINE_LOOP
00103 void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
00104 {
00105   while (__last - __first > 1)
00106     pop_heap(__first, __last--);
00107 }
00108 
00109 template <class _RandomAccessIterator, class _Compare>
00110 _STLP_INLINE_LOOP
00111 void 
00112 sort_heap(_RandomAccessIterator __first,
00113           _RandomAccessIterator __last, _Compare __comp)
00114 {
00115   while (__last - __first > 1)
00116     pop_heap(__first, __last--, __comp);
00117 }
00118 
00119 _STLP_END_NAMESPACE
00120 
00121 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
00122 #  include <stl/_heap.c>
00123 # endif
00124 
00125 #endif /* _STLP_INTERNAL_HEAP_H */
00126 
00127 // Local Variables:
00128 // mode:C++
00129 // End:

Generated on Mon Jun 5 10:20:46 2006 for Intelligence.kdevelop by  doxygen 1.4.6