diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlportv5/stl/_heap.c --- a/epoc32/include/stdapis/stlportv5/stl/_heap.c Wed Mar 31 12:27:01 2010 +0100 +++ b/epoc32/include/stdapis/stlportv5/stl/_heap.c Wed Mar 31 12:33:34 2010 +0100 @@ -10,13 +10,13 @@ * Copyright (c) 1997 * Moscow Center for SPARC Technology * - * Copyright (c) 1999 + * Copyright (c) 1999 * Boris Fomitchev * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * - * Permission to use or copy this software for any purpose is hereby granted + * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was @@ -38,7 +38,7 @@ template _STLP_INLINE_LOOP -void +void __push_heap(_RandomAccessIterator __first, _Distance __holeIndex, _Distance __topIndex, _Tp __val) { @@ -47,21 +47,21 @@ *(__first + __holeIndex) = *(__first + __parent); __holeIndex = __parent; __parent = (__holeIndex - 1) / 2; - } + } *(__first + __holeIndex) = __val; } template -inline void +inline void __push_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Distance*, _Tp*) { - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), + __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), _Tp(*(__last - 1))); } template -void +void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { __push_heap_aux(__first, __last, @@ -69,7 +69,7 @@ } -template _STLP_INLINE_LOOP void @@ -78,6 +78,7 @@ { _Distance __parent = (__holeIndex - 1) / 2; while (__holeIndex > __topIndex && __comp(*(__first + __parent), __val)) { + _STLP_VERBOSE_ASSERT(!__comp(__val, *(__first + __parent)), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) *(__first + __holeIndex) = *(__first + __parent); __holeIndex = __parent; __parent = (__holeIndex - 1) / 2; @@ -87,26 +88,26 @@ template -inline void +inline void __push_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, - _Distance*, _Tp*) + _Distance*, _Tp*) { - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), + __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), _Tp(*(__last - 1)), __comp); } template -void +void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp) + _Compare __comp) { __push_heap_aux(__first, __last, __comp, _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator), _STLP_VALUE_TYPE(__first, _RandomAccessIterator)); } template -void +void __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, _Distance __len, _Tp __val) { _Distance __topIndex = __holeIndex; @@ -127,15 +128,15 @@ template -inline void +inline void __pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp*) { - __pop_heap(__first, __last - 1, __last - 1, + __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator)); } template -void pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last) { +void pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last) { __pop_heap_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIterator)); } @@ -148,8 +149,11 @@ _Distance __topIndex = __holeIndex; _Distance __secondChild = 2 * __holeIndex + 2; while (__secondChild < __len) { - if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) + if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) { + _STLP_VERBOSE_ASSERT(!__comp(*(__first + (__secondChild - 1)), *(__first + __secondChild)), + _StlMsg_INVALID_STRICT_WEAK_PREDICATE) __secondChild--; + } *(__first + __holeIndex) = *(__first + __secondChild); __holeIndex = __secondChild; __secondChild = 2 * (__secondChild + 1); @@ -163,7 +167,7 @@ template -inline void +inline void __pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp*, _Compare __comp) { @@ -173,7 +177,7 @@ template -void +void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { @@ -182,15 +186,15 @@ template _STLP_INLINE_LOOP -void +void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp*, _Distance*) { if (__last - __first < 2) return; _Distance __len = __last - __first; _Distance __parent = (__len - 2)/2; - - while (true) { + + for (;;) { __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); if (__parent == 0) return; __parent--; @@ -198,7 +202,7 @@ } template -void +void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { __make_heap(__first, __last, @@ -215,8 +219,8 @@ if (__last - __first < 2) return; _Distance __len = __last - __first; _Distance __parent = (__len - 2)/2; - - while (true) { + + for (;;) { __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), __comp); if (__parent == 0) return; @@ -225,8 +229,8 @@ } template -void -make_heap(_RandomAccessIterator __first, +void +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { __make_heap(__first, __last, __comp,