Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_algo.h
Go to the documentation of this file.
00001 /* 00002 * 00003 * Copyright (c) 1994 00004 * Hewlett-Packard Company 00005 * 00006 * Copyright (c) 1996,1997 00007 * Silicon Graphics Computer Systems, Inc. 00008 * 00009 * Copyright (c) 1997 00010 * Moscow Center for SPARC Technology 00011 * 00012 * Copyright (c) 1999 00013 * Boris Fomitchev 00014 * 00015 * This material is provided "as is", with absolutely no warranty expressed 00016 * or implied. Any use is at your own risk. 00017 * 00018 * Permission to use or copy this software for any purpose is hereby granted 00019 * without fee, provided the above notices are retained on all copies. 00020 * Permission to modify the code and to distribute modified code is granted, 00021 * provided the above notices are retained, and a notice that the code was 00022 * modified is included with the above copyright notice. 00023 * 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_ALGO_H 00031 #define _STLP_INTERNAL_ALGO_H 00032 00033 #ifndef _STLP_INTERNAL_ALGOBASE_H 00034 # include <stl/_algobase.h> 00035 #endif 00036 00037 #ifndef _STLP_INTERNAL_HEAP_H 00038 # include <stl/_heap.h> 00039 #endif 00040 00041 #ifndef _STLP_INTERNAL_ITERATOR_H 00042 # include <stl/_iterator.h> 00043 #endif 00044 00045 #ifndef _STLP_INTERNAL_FUNCTION_BASE_H 00046 # include <stl/_function_base.h> 00047 #endif 00048 00049 #if defined (__SUNPRO_CC) && !defined (_STLP_INTERNAL_CSTDIO) 00050 // remove() conflict 00051 # include <stl/_cstdio.h> 00052 #endif 00053 00054 _STLP_BEGIN_NAMESPACE 00055 00056 // for_each. Apply a function to every element of a range. 00057 template <class _InputIter, class _Function> 00058 _STLP_INLINE_LOOP _Function 00059 for_each(_InputIter __first, _InputIter __last, _Function __f) { 00060 for ( ; __first != __last; ++__first) 00061 __f(*__first); 00062 return __f; 00063 } 00064 00065 // count_if 00066 template <class _InputIter, class _Predicate> 00067 _STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter) 00068 count_if(_InputIter __first, _InputIter __last, _Predicate __pred) { 00069 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00070 _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0; 00071 for ( ; __first != __last; ++__first) { 00072 if (__pred(*__first)) 00073 ++__n; 00074 } 00075 return __n; 00076 } 00077 00078 // adjacent_find. 00079 00080 template <class _ForwardIter, class _BinaryPredicate> 00081 _STLP_INLINE_LOOP _ForwardIter 00082 adjacent_find(_ForwardIter __first, _ForwardIter __last, 00083 _BinaryPredicate __binary_pred) { 00084 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00085 if (__first == __last) 00086 return __last; 00087 _ForwardIter __next = __first; 00088 while(++__next != __last) { 00089 if (__binary_pred(*__first, *__next)) 00090 return __first; 00091 __first = __next; 00092 } 00093 return __last; 00094 } 00095 00096 template <class _ForwardIter> 00097 _STLP_INLINE_LOOP _ForwardIter 00098 adjacent_find(_ForwardIter __first, _ForwardIter __last) { 00099 return adjacent_find(__first, __last, 00100 _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first, _ForwardIter))); 00101 } 00102 00103 #if !defined (_STLP_NO_ANACHRONISMS) 00104 template <class _InputIter, class _Tp, class _Size> 00105 _STLP_INLINE_LOOP void 00106 count(_InputIter __first, _InputIter __last, const _Tp& __val, _Size& __n) { 00107 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00108 for ( ; __first != __last; ++__first) 00109 if (*__first == __val) 00110 ++__n; 00111 } 00112 00113 template <class _InputIter, class _Predicate, class _Size> 00114 _STLP_INLINE_LOOP void 00115 count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size& __n) { 00116 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00117 for ( ; __first != __last; ++__first) 00118 if (__pred(*__first)) 00119 ++__n; 00120 } 00121 #endif 00122 00123 template <class _ForwardIter1, class _ForwardIter2> 00124 _ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, 00125 _ForwardIter2 __first2, _ForwardIter2 __last2); 00126 00127 // search_n. Search for __count consecutive copies of __val. 00128 template <class _ForwardIter, class _Integer, class _Tp> 00129 _ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, 00130 _Integer __count, const _Tp& __val); 00131 template <class _ForwardIter, class _Integer, class _Tp, class _BinaryPred> 00132 _ForwardIter search_n(_ForwardIter __first, _ForwardIter __last, 00133 _Integer __count, const _Tp& __val, _BinaryPred __binary_pred); 00134 00135 template <class _InputIter, class _ForwardIter> 00136 inline _InputIter find_first_of(_InputIter __first1, _InputIter __last1, 00137 _ForwardIter __first2, _ForwardIter __last2) { 00138 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) 00139 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) 00140 return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2); 00141 } 00142 00143 template <class _InputIter, class _ForwardIter, class _BinaryPredicate> 00144 inline _InputIter 00145 find_first_of(_InputIter __first1, _InputIter __last1, 00146 _ForwardIter __first2, _ForwardIter __last2, _BinaryPredicate __comp) { 00147 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) 00148 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) 00149 return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2, __comp); 00150 } 00151 00152 template <class _ForwardIter1, class _ForwardIter2> 00153 _ForwardIter1 00154 find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, 00155 _ForwardIter2 __first2, _ForwardIter2 __last2); 00156 00157 // swap_ranges 00158 template <class _ForwardIter1, class _ForwardIter2> 00159 _STLP_INLINE_LOOP _ForwardIter2 00160 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2) { 00161 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) 00162 for ( ; __first1 != __last1; ++__first1, ++__first2) 00163 iter_swap(__first1, __first2); 00164 return __first2; 00165 } 00166 00167 // transform 00168 template <class _InputIter, class _OutputIter, class _UnaryOperation> 00169 _STLP_INLINE_LOOP _OutputIter 00170 transform(_InputIter __first, _InputIter __last, _OutputIter __result, _UnaryOperation __opr) { 00171 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00172 for ( ; __first != __last; ++__first, ++__result) 00173 *__result = __opr(*__first); 00174 return __result; 00175 } 00176 template <class _InputIter1, class _InputIter2, class _OutputIter, class _BinaryOperation> 00177 _STLP_INLINE_LOOP _OutputIter 00178 transform(_InputIter1 __first1, _InputIter1 __last1, 00179 _InputIter2 __first2, _OutputIter __result,_BinaryOperation __binary_op) { 00180 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) 00181 for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result) 00182 *__result = __binary_op(*__first1, *__first2); 00183 return __result; 00184 } 00185 00186 // replace_if, replace_copy, replace_copy_if 00187 00188 template <class _ForwardIter, class _Predicate, class _Tp> 00189 _STLP_INLINE_LOOP void 00190 replace_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred, const _Tp& __new_value) { 00191 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00192 for ( ; __first != __last; ++__first) 00193 if (__pred(*__first)) 00194 *__first = __new_value; 00195 } 00196 00197 template <class _InputIter, class _OutputIter, class _Tp> 00198 _STLP_INLINE_LOOP _OutputIter 00199 replace_copy(_InputIter __first, _InputIter __last,_OutputIter __result, 00200 const _Tp& __old_value, const _Tp& __new_value) { 00201 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00202 for ( ; __first != __last; ++__first, ++__result) 00203 *__result = *__first == __old_value ? __new_value : *__first; 00204 return __result; 00205 } 00206 00207 template <class _Iterator, class _OutputIter, class _Predicate, class _Tp> 00208 _STLP_INLINE_LOOP _OutputIter 00209 replace_copy_if(_Iterator __first, _Iterator __last, 00210 _OutputIter __result, 00211 _Predicate __pred, const _Tp& __new_value) { 00212 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00213 for ( ; __first != __last; ++__first, ++__result) 00214 *__result = __pred(*__first) ? __new_value : *__first; 00215 return __result; 00216 } 00217 00218 // generate and generate_n 00219 00220 template <class _ForwardIter, class _Generator> 00221 _STLP_INLINE_LOOP void 00222 generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) { 00223 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00224 for ( ; __first != __last; ++__first) 00225 *__first = __gen(); 00226 } 00227 00228 template <class _OutputIter, class _Size, class _Generator> 00229 _STLP_INLINE_LOOP void 00230 generate_n(_OutputIter __first, _Size __n, _Generator __gen) { 00231 for ( ; __n > 0; --__n, ++__first) 00232 *__first = __gen(); 00233 } 00234 00235 // remove, remove_if, remove_copy, remove_copy_if 00236 00237 template <class _InputIter, class _OutputIter, class _Tp> 00238 _STLP_INLINE_LOOP _OutputIter 00239 remove_copy(_InputIter __first, _InputIter __last,_OutputIter __result, const _Tp& __val) { 00240 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00241 for ( ; __first != __last; ++__first) { 00242 if (!(*__first == __val)) { 00243 *__result = *__first; 00244 ++__result; 00245 } 00246 } 00247 return __result; 00248 } 00249 00250 template <class _InputIter, class _OutputIter, class _Predicate> 00251 _STLP_INLINE_LOOP _OutputIter 00252 remove_copy_if(_InputIter __first, _InputIter __last, _OutputIter __result, _Predicate __pred) { 00253 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00254 for ( ; __first != __last; ++__first) { 00255 if (!__pred(*__first)) { 00256 *__result = *__first; 00257 ++__result; 00258 } 00259 } 00260 return __result; 00261 } 00262 00263 template <class _ForwardIter, class _Tp> 00264 _STLP_INLINE_LOOP _ForwardIter 00265 remove(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { 00266 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00267 __first = find(__first, __last, __val); 00268 if (__first == __last) 00269 return __first; 00270 else { 00271 _ForwardIter __next = __first; 00272 return remove_copy(++__next, __last, __first, __val); 00273 } 00274 } 00275 00276 template <class _ForwardIter, class _Predicate> 00277 _STLP_INLINE_LOOP _ForwardIter 00278 remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) { 00279 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00280 __first = find_if(__first, __last, __pred); 00281 if ( __first == __last ) 00282 return __first; 00283 else { 00284 _ForwardIter __next = __first; 00285 return remove_copy_if(++__next, __last, __first, __pred); 00286 } 00287 } 00288 00289 // unique and unique_copy 00290 template <class _InputIter, class _OutputIter> 00291 _OutputIter unique_copy(_InputIter __first, _InputIter __last, _OutputIter __result); 00292 00293 template <class _InputIter, class _OutputIter, class _BinaryPredicate> 00294 _OutputIter unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result, 00295 _BinaryPredicate __binary_pred); 00296 00297 template <class _ForwardIter> 00298 inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last) { 00299 __first = adjacent_find(__first, __last); 00300 return unique_copy(__first, __last, __first); 00301 } 00302 00303 template <class _ForwardIter, class _BinaryPredicate> 00304 inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last, 00305 _BinaryPredicate __binary_pred) { 00306 __first = adjacent_find(__first, __last, __binary_pred); 00307 return unique_copy(__first, __last, __first, __binary_pred); 00308 } 00309 00310 // reverse and reverse_copy, and their auxiliary functions 00311 00312 _STLP_MOVE_TO_PRIV_NAMESPACE 00313 00314 template <class _BidirectionalIter> 00315 _STLP_INLINE_LOOP void 00316 __reverse(_BidirectionalIter __first, _BidirectionalIter __last, const bidirectional_iterator_tag &) { 00317 for (; __first != __last && __first != --__last; ++__first) 00318 _STLP_STD::iter_swap(__first,__last); 00319 } 00320 00321 template <class _RandomAccessIter> 00322 _STLP_INLINE_LOOP void 00323 __reverse(_RandomAccessIter __first, _RandomAccessIter __last, const random_access_iterator_tag &) { 00324 for (; __first < __last; ++__first) 00325 _STLP_STD::iter_swap(__first, --__last); 00326 } 00327 00328 _STLP_MOVE_TO_STD_NAMESPACE 00329 00330 template <class _BidirectionalIter> 00331 inline void 00332 reverse(_BidirectionalIter __first, _BidirectionalIter __last) { 00333 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00334 _STLP_PRIV __reverse(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _BidirectionalIter)); 00335 } 00336 00337 template <class _BidirectionalIter, class _OutputIter> 00338 _STLP_INLINE_LOOP 00339 _OutputIter reverse_copy(_BidirectionalIter __first, 00340 _BidirectionalIter __last, 00341 _OutputIter __result) { 00342 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00343 while (__first != __last) { 00344 --__last; 00345 *__result = *__last; 00346 ++__result; 00347 } 00348 return __result; 00349 } 00350 00351 template <class _ForwardIter> 00352 void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last); 00353 00354 template <class _ForwardIter, class _OutputIter> 00355 inline _OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle, 00356 _ForwardIter __last, _OutputIter __result) { 00357 return _STLP_STD::copy(__first, __middle, copy(__middle, __last, __result)); 00358 } 00359 00360 // random_shuffle 00361 00362 template <class _RandomAccessIter> 00363 void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last); 00364 00365 template <class _RandomAccessIter, class _RandomNumberGenerator> 00366 void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last, 00367 _RandomNumberGenerator& __rand); 00368 00369 #if !defined (_STLP_NO_EXTENSIONS) 00370 // random_sample and random_sample_n (extensions, not part of the standard). 00371 00372 template <class _ForwardIter, class _OutputIter, class _Distance> 00373 _OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, 00374 _OutputIter __out_ite, const _Distance __n); 00375 00376 template <class _ForwardIter, class _OutputIter, class _Distance, 00377 class _RandomNumberGenerator> 00378 _OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last, 00379 _OutputIter __out_ite, const _Distance __n, 00380 _RandomNumberGenerator& __rand); 00381 00382 template <class _InputIter, class _RandomAccessIter> 00383 _RandomAccessIter 00384 random_sample(_InputIter __first, _InputIter __last, 00385 _RandomAccessIter __out_first, _RandomAccessIter __out_last); 00386 00387 template <class _InputIter, class _RandomAccessIter, 00388 class _RandomNumberGenerator> 00389 _RandomAccessIter 00390 random_sample(_InputIter __first, _InputIter __last, 00391 _RandomAccessIter __out_first, _RandomAccessIter __out_last, 00392 _RandomNumberGenerator& __rand); 00393 00394 #endif /* _STLP_NO_EXTENSIONS */ 00395 00396 // partition, stable_partition, and their auxiliary functions 00397 00398 template <class _ForwardIter, class _Predicate> 00399 _ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred); 00400 00401 template <class _ForwardIter, class _Predicate> 00402 _ForwardIter 00403 stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred); 00404 00405 // sort() and its auxiliary functions. 00406 _STLP_MOVE_TO_PRIV_NAMESPACE 00407 00408 template <class _Size> 00409 inline _Size __lg(_Size __n) { 00410 _Size __k; 00411 for (__k = 0; __n != 1; __n >>= 1) ++__k; 00412 return __k; 00413 } 00414 00415 _STLP_MOVE_TO_STD_NAMESPACE 00416 00417 template <class _RandomAccessIter> 00418 void sort(_RandomAccessIter __first, _RandomAccessIter __last); 00419 template <class _RandomAccessIter, class _Compare> 00420 void sort(_RandomAccessIter __first, _RandomAccessIter __last, _Compare __comp); 00421 00422 // stable_sort() and its auxiliary functions. 00423 template <class _RandomAccessIter> 00424 void stable_sort(_RandomAccessIter __first, 00425 _RandomAccessIter __last); 00426 00427 template <class _RandomAccessIter, class _Compare> 00428 void stable_sort(_RandomAccessIter __first, 00429 _RandomAccessIter __last, _Compare __comp); 00430 00431 // partial_sort, partial_sort_copy, and auxiliary functions. 00432 00433 template <class _RandomAccessIter> 00434 void partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, 00435 _RandomAccessIter __last); 00436 00437 template <class _RandomAccessIter, class _Compare> 00438 void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, 00439 _RandomAccessIter __last, _Compare __comp); 00440 00441 template <class _InputIter, class _RandomAccessIter> 00442 _RandomAccessIter 00443 partial_sort_copy(_InputIter __first, _InputIter __last, 00444 _RandomAccessIter __result_first, _RandomAccessIter __result_last); 00445 00446 template <class _InputIter, class _RandomAccessIter, class _Compare> 00447 _RandomAccessIter 00448 partial_sort_copy(_InputIter __first, _InputIter __last, 00449 _RandomAccessIter __result_first, 00450 _RandomAccessIter __result_last, _Compare __comp); 00451 00452 // nth_element() and its auxiliary functions. 00453 template <class _RandomAccessIter> 00454 void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, 00455 _RandomAccessIter __last); 00456 00457 template <class _RandomAccessIter, class _Compare> 00458 void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, 00459 _RandomAccessIter __last, _Compare __comp); 00460 00461 // auxiliary class for lower_bound, etc. 00462 _STLP_MOVE_TO_PRIV_NAMESPACE 00463 00464 template <class _T1, class _T2> 00465 struct __less_2 { 00466 bool operator() (const _T1& __x, const _T2& __y) const { return __x < __y ; } 00467 }; 00468 00469 template <class _T1, class _T2> 00470 __less_2<_T1,_T2> __less2(_T1*, _T2* ) { return __less_2<_T1, _T2>(); } 00471 00472 #if defined (_STLP_FUNCTION_PARTIAL_ORDER) 00473 template <class _Tp> 00474 less<_Tp> __less2(_Tp*, _Tp* ) { return less<_Tp>(); } 00475 #endif 00476 00477 _STLP_MOVE_TO_STD_NAMESPACE 00478 00479 // Binary search (lower_bound, upper_bound, equal_range, binary_search). 00480 template <class _ForwardIter, class _Tp> 00481 inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, 00482 const _Tp& __val) { 00483 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00484 return _STLP_PRIV __lower_bound(__first, __last, __val, 00485 _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), 00486 _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), 00487 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00488 } 00489 00490 template <class _ForwardIter, class _Tp, class _Compare> 00491 inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, 00492 const _Tp& __val, _Compare __comp) { 00493 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00494 return _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp, 00495 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00496 } 00497 00498 _STLP_MOVE_TO_PRIV_NAMESPACE 00499 00500 template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance> 00501 _ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, 00502 _Compare1 __comp1, _Compare2 __comp2, _Distance*); 00503 00504 _STLP_MOVE_TO_STD_NAMESPACE 00505 00506 template <class _ForwardIter, class _Tp> 00507 inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, 00508 const _Tp& __val) { 00509 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00510 return _STLP_PRIV __upper_bound(__first, __last, __val, 00511 _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), 00512 _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), 00513 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00514 } 00515 00516 template <class _ForwardIter, class _Tp, class _Compare> 00517 inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, 00518 const _Tp& __val, _Compare __comp) { 00519 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00520 return _STLP_PRIV __upper_bound(__first, __last, __val, __comp, __comp, 00521 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00522 } 00523 00524 _STLP_MOVE_TO_PRIV_NAMESPACE 00525 00526 template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance> 00527 pair<_ForwardIter, _ForwardIter> 00528 __equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, 00529 _Compare1 __comp1, _Compare2 __comp2, _Distance*); 00530 00531 _STLP_MOVE_TO_STD_NAMESPACE 00532 00533 template <class _ForwardIter, class _Tp> 00534 inline pair<_ForwardIter, _ForwardIter> 00535 equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { 00536 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00537 return _STLP_PRIV __equal_range(__first, __last, __val, 00538 _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), 00539 _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), 00540 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00541 } 00542 00543 template <class _ForwardIter, class _Tp, class _Compare> 00544 inline pair<_ForwardIter, _ForwardIter> 00545 equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, 00546 _Compare __comp) { 00547 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00548 return _STLP_PRIV __equal_range(__first, __last, __val, __comp, __comp, 00549 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00550 } 00551 00552 template <class _ForwardIter, class _Tp> 00553 inline bool binary_search(_ForwardIter __first, _ForwardIter __last, 00554 const _Tp& __val) { 00555 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00556 _ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val, 00557 _STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0), 00558 _STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)), 00559 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00560 return __i != __last && !(__val < *__i); 00561 } 00562 00563 template <class _ForwardIter, class _Tp, class _Compare> 00564 inline bool binary_search(_ForwardIter __first, _ForwardIter __last, 00565 const _Tp& __val, 00566 _Compare __comp) { 00567 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00568 _ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp, 00569 _STLP_DISTANCE_TYPE(__first, _ForwardIter)); 00570 return __i != __last && !__comp(__val, *__i); 00571 } 00572 00573 // merge, with and without an explicitly supplied comparison function. 00574 00575 template <class _InputIter1, class _InputIter2, class _OutputIter> 00576 _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, 00577 _InputIter2 __first2, _InputIter2 __last2, 00578 _OutputIter __result); 00579 00580 template <class _InputIter1, class _InputIter2, class _OutputIter, 00581 class _Compare> 00582 _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, 00583 _InputIter2 __first2, _InputIter2 __last2, 00584 _OutputIter __result, _Compare __comp); 00585 00586 00587 // inplace_merge and its auxiliary functions. 00588 00589 00590 template <class _BidirectionalIter> 00591 void inplace_merge(_BidirectionalIter __first, 00592 _BidirectionalIter __middle, 00593 _BidirectionalIter __last) ; 00594 00595 template <class _BidirectionalIter, class _Compare> 00596 void inplace_merge(_BidirectionalIter __first, 00597 _BidirectionalIter __middle, 00598 _BidirectionalIter __last, _Compare __comp); 00599 00600 // Set algorithms: includes, set_union, set_intersection, set_difference, 00601 // set_symmetric_difference. All of these algorithms have the precondition 00602 // that their input ranges are sorted and the postcondition that their output 00603 // ranges are sorted. 00604 00605 template <class _InputIter1, class _InputIter2> 00606 bool includes(_InputIter1 __first1, _InputIter1 __last1, 00607 _InputIter2 __first2, _InputIter2 __last2); 00608 00609 template <class _InputIter1, class _InputIter2, class _Compare> 00610 bool includes(_InputIter1 __first1, _InputIter1 __last1, 00611 _InputIter2 __first2, _InputIter2 __last2, _Compare __comp); 00612 00613 template <class _InputIter1, class _InputIter2, class _OutputIter> 00614 _OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, 00615 _InputIter2 __first2, _InputIter2 __last2, 00616 _OutputIter __result); 00617 00618 template <class _InputIter1, class _InputIter2, class _OutputIter, 00619 class _Compare> 00620 _OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1, 00621 _InputIter2 __first2, _InputIter2 __last2, 00622 _OutputIter __result, _Compare __comp); 00623 00624 template <class _InputIter1, class _InputIter2, class _OutputIter> 00625 _OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, 00626 _InputIter2 __first2, _InputIter2 __last2, 00627 _OutputIter __result); 00628 00629 template <class _InputIter1, class _InputIter2, class _OutputIter, 00630 class _Compare> 00631 _OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1, 00632 _InputIter2 __first2, _InputIter2 __last2, 00633 _OutputIter __result, _Compare __comp); 00634 00635 00636 00637 template <class _InputIter1, class _InputIter2, class _OutputIter> 00638 _OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, 00639 _InputIter2 __first2, _InputIter2 __last2, 00640 _OutputIter __result); 00641 00642 template <class _InputIter1, class _InputIter2, class _OutputIter, 00643 class _Compare> 00644 _OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1, 00645 _InputIter2 __first2, _InputIter2 __last2, 00646 _OutputIter __result, _Compare __comp); 00647 00648 template <class _InputIter1, class _InputIter2, class _OutputIter> 00649 _OutputIter 00650 set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, 00651 _InputIter2 __first2, _InputIter2 __last2, 00652 _OutputIter __result); 00653 00654 00655 template <class _InputIter1, class _InputIter2, class _OutputIter, 00656 class _Compare> 00657 _OutputIter 00658 set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1, 00659 _InputIter2 __first2, _InputIter2 __last2, 00660 _OutputIter __result, 00661 _Compare __comp); 00662 00663 00664 // min_element and max_element, with and without an explicitly supplied 00665 // comparison function. 00666 00667 template <class _ForwardIter> 00668 _ForwardIter max_element(_ForwardIter __first, _ForwardIter __last); 00669 template <class _ForwardIter, class _Compare> 00670 _ForwardIter max_element(_ForwardIter __first, _ForwardIter __last, 00671 _Compare __comp); 00672 00673 template <class _ForwardIter> 00674 _ForwardIter min_element(_ForwardIter __first, _ForwardIter __last); 00675 00676 template <class _ForwardIter, class _Compare> 00677 _ForwardIter min_element(_ForwardIter __first, _ForwardIter __last, 00678 _Compare __comp); 00679 00680 // next_permutation and prev_permutation, with and without an explicitly 00681 // supplied comparison function. 00682 00683 template <class _BidirectionalIter> 00684 bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last); 00685 00686 template <class _BidirectionalIter, class _Compare> 00687 bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last, 00688 _Compare __comp); 00689 00690 00691 template <class _BidirectionalIter> 00692 bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last); 00693 00694 00695 template <class _BidirectionalIter, class _Compare> 00696 bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last, 00697 _Compare __comp); 00698 00699 #if !defined (_STLP_NO_EXTENSIONS) 00700 // is_heap, a predicate testing whether or not a range is 00701 // a heap. This function is an extension, not part of the C++ 00702 // standard. 00703 00704 template <class _RandomAccessIter> 00705 bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last); 00706 00707 template <class _RandomAccessIter, class _StrictWeakOrdering> 00708 bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last, 00709 _StrictWeakOrdering __comp); 00710 00711 // is_sorted, a predicated testing whether a range is sorted in 00712 // nondescending order. This is an extension, not part of the C++ 00713 // standard. 00714 _STLP_MOVE_TO_PRIV_NAMESPACE 00715 00716 template <class _ForwardIter, class _StrictWeakOrdering> 00717 bool __is_sorted(_ForwardIter __first, _ForwardIter __last, 00718 _StrictWeakOrdering __comp); 00719 00720 _STLP_MOVE_TO_STD_NAMESPACE 00721 template <class _ForwardIter> 00722 inline bool is_sorted(_ForwardIter __first, _ForwardIter __last) { 00723 return _STLP_PRIV __is_sorted(__first, __last, 00724 _STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _ForwardIter))); 00725 } 00726 00727 template <class _ForwardIter, class _StrictWeakOrdering> 00728 inline bool is_sorted(_ForwardIter __first, _ForwardIter __last, 00729 _StrictWeakOrdering __comp) { 00730 return _STLP_PRIV __is_sorted(__first, __last, __comp); 00731 } 00732 #endif 00733 00734 _STLP_END_NAMESPACE 00735 00736 #if !defined (_STLP_LINK_TIME_INSTANTIATION) 00737 # include <stl/_algo.c> 00738 #endif 00739 00740 #endif /* _STLP_INTERNAL_ALGO_H */ 00741 00742 // Local Variables: 00743 // mode:C++ 00744 // End: 00745 Generated on Sat May 26 2012 04:27:28 for ReactOS by
1.7.6.1
|