epoc32/include/stdapis/stlportv5/stl/_heap.c
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_heap.c	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_heap.c	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -10,13 +10,13 @@
     1.4   * Copyright (c) 1997
     1.5   * Moscow Center for SPARC Technology
     1.6   *
     1.7 - * Copyright (c) 1999 
     1.8 + * Copyright (c) 1999
     1.9   * Boris Fomitchev
    1.10   *
    1.11   * This material is provided "as is", with absolutely no warranty expressed
    1.12   * or implied. Any use is at your own risk.
    1.13   *
    1.14 - * Permission to use or copy this software for any purpose is hereby granted 
    1.15 + * Permission to use or copy this software for any purpose is hereby granted
    1.16   * without fee, provided the above notices are retained on all copies.
    1.17   * Permission to modify the code and to distribute modified code is granted,
    1.18   * provided the above notices are retained, and a notice that the code was
    1.19 @@ -38,7 +38,7 @@
    1.20  
    1.21  template <class _RandomAccessIterator, class _Distance, class _Tp>
    1.22  _STLP_INLINE_LOOP
    1.23 -void 
    1.24 +void
    1.25  __push_heap(_RandomAccessIterator __first,
    1.26              _Distance __holeIndex, _Distance __topIndex, _Tp __val)
    1.27  {
    1.28 @@ -47,21 +47,21 @@
    1.29      *(__first + __holeIndex) = *(__first + __parent);
    1.30      __holeIndex = __parent;
    1.31      __parent = (__holeIndex - 1) / 2;
    1.32 -  }    
    1.33 +  }
    1.34    *(__first + __holeIndex) = __val;
    1.35  }
    1.36  
    1.37  template <class _RandomAccessIterator, class _Distance, class _Tp>
    1.38 -inline void 
    1.39 +inline void
    1.40  __push_heap_aux(_RandomAccessIterator __first,
    1.41                  _RandomAccessIterator __last, _Distance*, _Tp*)
    1.42  {
    1.43 -  __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), 
    1.44 +  __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
    1.45                _Tp(*(__last - 1)));
    1.46  }
    1.47  
    1.48  template <class _RandomAccessIterator>
    1.49 -void 
    1.50 +void
    1.51  push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
    1.52  {
    1.53    __push_heap_aux(__first, __last,
    1.54 @@ -69,7 +69,7 @@
    1.55  }
    1.56  
    1.57  
    1.58 -template <class _RandomAccessIterator, class _Distance, class _Tp, 
    1.59 +template <class _RandomAccessIterator, class _Distance, class _Tp,
    1.60            class _Compare>
    1.61  _STLP_INLINE_LOOP
    1.62  void
    1.63 @@ -78,6 +78,7 @@
    1.64  {
    1.65    _Distance __parent = (__holeIndex - 1) / 2;
    1.66    while (__holeIndex > __topIndex && __comp(*(__first + __parent), __val)) {
    1.67 +    _STLP_VERBOSE_ASSERT(!__comp(__val, *(__first + __parent)), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
    1.68      *(__first + __holeIndex) = *(__first + __parent);
    1.69      __holeIndex = __parent;
    1.70      __parent = (__holeIndex - 1) / 2;
    1.71 @@ -87,26 +88,26 @@
    1.72  
    1.73  template <class _RandomAccessIterator, class _Compare,
    1.74            class _Distance, class _Tp>
    1.75 -inline void 
    1.76 +inline void
    1.77  __push_heap_aux(_RandomAccessIterator __first,
    1.78                  _RandomAccessIterator __last, _Compare __comp,
    1.79 -                _Distance*, _Tp*) 
    1.80 +                _Distance*, _Tp*)
    1.81  {
    1.82 -  __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), 
    1.83 +  __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
    1.84                _Tp(*(__last - 1)), __comp);
    1.85  }
    1.86  
    1.87  template <class _RandomAccessIterator, class _Compare>
    1.88 -void 
    1.89 +void
    1.90  push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
    1.91 -          _Compare __comp) 
    1.92 +          _Compare __comp)
    1.93  {
    1.94    __push_heap_aux(__first, __last, __comp,
    1.95                    _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator), _STLP_VALUE_TYPE(__first, _RandomAccessIterator));
    1.96  }
    1.97  
    1.98  template <class _RandomAccessIterator, class _Distance, class _Tp>
    1.99 -void 
   1.100 +void
   1.101  __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
   1.102                _Distance __len, _Tp __val) {
   1.103    _Distance __topIndex = __holeIndex;
   1.104 @@ -127,15 +128,15 @@
   1.105  
   1.106  
   1.107  template <class _RandomAccessIterator, class _Tp>
   1.108 -inline void 
   1.109 +inline void
   1.110  __pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp*) {
   1.111 -  __pop_heap(__first, __last - 1, __last - 1, 
   1.112 +  __pop_heap(__first, __last - 1, __last - 1,
   1.113               _Tp(*(__last - 1)), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator));
   1.114  }
   1.115  
   1.116  template <class _RandomAccessIterator>
   1.117 -void pop_heap(_RandomAccessIterator __first, 
   1.118 -	      _RandomAccessIterator __last) {
   1.119 +void pop_heap(_RandomAccessIterator __first,
   1.120 +        _RandomAccessIterator __last) {
   1.121    __pop_heap_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIterator));
   1.122  }
   1.123  
   1.124 @@ -148,8 +149,11 @@
   1.125    _Distance __topIndex = __holeIndex;
   1.126    _Distance __secondChild = 2 * __holeIndex + 2;
   1.127    while (__secondChild < __len) {
   1.128 -    if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1))))
   1.129 +    if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) {
   1.130 +      _STLP_VERBOSE_ASSERT(!__comp(*(__first + (__secondChild - 1)), *(__first + __secondChild)),
   1.131 +                           _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
   1.132        __secondChild--;
   1.133 +    }
   1.134      *(__first + __holeIndex) = *(__first + __secondChild);
   1.135      __holeIndex = __secondChild;
   1.136      __secondChild = 2 * (__secondChild + 1);
   1.137 @@ -163,7 +167,7 @@
   1.138  
   1.139  
   1.140  template <class _RandomAccessIterator, class _Tp, class _Compare>
   1.141 -inline void 
   1.142 +inline void
   1.143  __pop_heap_aux(_RandomAccessIterator __first,
   1.144                 _RandomAccessIterator __last, _Tp*, _Compare __comp)
   1.145  {
   1.146 @@ -173,7 +177,7 @@
   1.147  
   1.148  
   1.149  template <class _RandomAccessIterator, class _Compare>
   1.150 -void 
   1.151 +void
   1.152  pop_heap(_RandomAccessIterator __first,
   1.153           _RandomAccessIterator __last, _Compare __comp)
   1.154  {
   1.155 @@ -182,15 +186,15 @@
   1.156  
   1.157  template <class _RandomAccessIterator, class _Tp, class _Distance>
   1.158  _STLP_INLINE_LOOP
   1.159 -void 
   1.160 +void
   1.161  __make_heap(_RandomAccessIterator __first,
   1.162              _RandomAccessIterator __last, _Tp*, _Distance*)
   1.163  {
   1.164    if (__last - __first < 2) return;
   1.165    _Distance __len = __last - __first;
   1.166    _Distance __parent = (__len - 2)/2;
   1.167 -    
   1.168 -  while (true) {
   1.169 +
   1.170 +  for (;;) {
   1.171      __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)));
   1.172      if (__parent == 0) return;
   1.173      __parent--;
   1.174 @@ -198,7 +202,7 @@
   1.175  }
   1.176  
   1.177  template <class _RandomAccessIterator>
   1.178 -void 
   1.179 +void
   1.180  make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
   1.181  {
   1.182    __make_heap(__first, __last,
   1.183 @@ -215,8 +219,8 @@
   1.184    if (__last - __first < 2) return;
   1.185    _Distance __len = __last - __first;
   1.186    _Distance __parent = (__len - 2)/2;
   1.187 -    
   1.188 -  while (true) {
   1.189 +
   1.190 +  for (;;) {
   1.191      __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)),
   1.192                    __comp);
   1.193      if (__parent == 0) return;
   1.194 @@ -225,8 +229,8 @@
   1.195  }
   1.196  
   1.197  template <class _RandomAccessIterator, class _Compare>
   1.198 -void 
   1.199 -make_heap(_RandomAccessIterator __first, 
   1.200 +void
   1.201 +make_heap(_RandomAccessIterator __first,
   1.202            _RandomAccessIterator __last, _Compare __comp)
   1.203  {
   1.204    __make_heap(__first, __last, __comp,