/home/ntakagi/work/STLport-5.1.5/stlport/stl/_heap.h

Go to the documentation of this file.
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 _STLP_BEGIN_NAMESPACE
00034 
00035 // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
00036 
00037 template <class _RandomAccessIterator>
00038 void
00039 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
00040 
00041 
00042 template <class _RandomAccessIterator, class _Compare>
00043 void
00044 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00045           _Compare __comp);
00046 
00047 template <class _RandomAccessIterator, class _Distance, class _Tp>
00048 void
00049 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
00050               _Distance __len, _Tp __val);
00051 
00052 template <class _RandomAccessIterator, class _Tp, class _Distance>
00053 inline void
00054 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00055            _RandomAccessIterator __result, _Tp __val, _Distance*)
00056 {
00057   *__result = *__first;
00058   __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __val);
00059 }
00060 
00061 template <class _RandomAccessIterator>
00062 void pop_heap(_RandomAccessIterator __first,
00063         _RandomAccessIterator __last);
00064 
00065 template <class _RandomAccessIterator, class _Distance,
00066           class _Tp, class _Compare>
00067 void
00068 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
00069               _Distance __len, _Tp __val, _Compare __comp);
00070 
00071 template <class _RandomAccessIterator, class _Tp, class _Compare,
00072           class _Distance>
00073 inline void
00074 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00075            _RandomAccessIterator __result, _Tp __val, _Compare __comp,
00076            _Distance*)
00077 {
00078   *__result = *__first;
00079   __adjust_heap(__first, _Distance(0), _Distance(__last - __first),
00080                 __val, __comp);
00081 }
00082 
00083 template <class _RandomAccessIterator, class _Compare>
00084 void
00085 pop_heap(_RandomAccessIterator __first,
00086          _RandomAccessIterator __last, _Compare __comp);
00087 
00088 template <class _RandomAccessIterator>
00089 void
00090 make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
00091 
00092 template <class _RandomAccessIterator, class _Compare>
00093 void
00094 make_heap(_RandomAccessIterator __first,
00095           _RandomAccessIterator __last, _Compare __comp);
00096 
00097 template <class _RandomAccessIterator>
00098 _STLP_INLINE_LOOP
00099 void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
00100 {
00101   while (__last - __first > 1)
00102     pop_heap(__first, __last--);
00103 }
00104 
00105 template <class _RandomAccessIterator, class _Compare>
00106 _STLP_INLINE_LOOP
00107 void
00108 sort_heap(_RandomAccessIterator __first,
00109           _RandomAccessIterator __last, _Compare __comp)
00110 {
00111   while (__last - __first > 1)
00112     pop_heap(__first, __last--, __comp);
00113 }
00114 
00115 _STLP_END_NAMESPACE
00116 
00117 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
00118 #  include <stl/_heap.c>
00119 # endif
00120 
00121 #endif /* _STLP_INTERNAL_HEAP_H */
00122 
00123 // Local Variables:
00124 // mode:C++
00125 // End:



Generated on Mon Mar 10 15:32:25 2008 by  doxygen 1.5.1