1.1 --- a/epoc32/include/stdapis/stlport/stl/_algobase.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,583 +0,0 @@
1.4 -/*
1.5 - *
1.6 - * Copyright (c) 1994
1.7 - * Hewlett-Packard Company
1.8 - *
1.9 - * Copyright (c) 1996,1997
1.10 - * Silicon Graphics Computer Systems, Inc.
1.11 - *
1.12 - * Copyright (c) 1997
1.13 - * Moscow Center for SPARC Technology
1.14 - *
1.15 - * Copyright (c) 1999
1.16 - * Boris Fomitchev
1.17 - *
1.18 - * This material is provided "as is", with absolutely no warranty expressed
1.19 - * or implied. Any use is at your own risk.
1.20 - *
1.21 - * Permission to use or copy this software for any purpose is hereby granted
1.22 - * without fee, provided the above notices are retained on all copies.
1.23 - * Permission to modify the code and to distribute modified code is granted,
1.24 - * provided the above notices are retained, and a notice that the code was
1.25 - * modified is included with the above copyright notice.
1.26 - *
1.27 - */
1.28 -
1.29 -/* NOTE: This is an internal header file, included by other STL headers.
1.30 - * You should not attempt to use it directly.
1.31 - */
1.32 -
1.33 -
1.34 -#ifndef _STLP_INTERNAL_ALGOBASE_H
1.35 -#define _STLP_INTERNAL_ALGOBASE_H
1.36 -
1.37 -# if ! defined (_STLP_CSTDDEF)
1.38 -# include <cstddef>
1.39 -# endif
1.40 -
1.41 -#ifndef _STLP_CSTRING
1.42 -# include <cstring>
1.43 -#endif
1.44 -
1.45 -#ifndef _STLP_CLIMITS
1.46 -# include <climits>
1.47 -#endif
1.48 -
1.49 -# if ! defined (_STLP_CSTDLIB)
1.50 -# include <cstdlib>
1.51 -# endif
1.52 -
1.53 -# ifndef _STLP_INTERNAL_PAIR_H
1.54 -# include <stl/_pair.h>
1.55 -# endif
1.56 -
1.57 -#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.58 -# include <stl/_iterator_base.h>
1.59 -#endif
1.60 -
1.61 -_STLP_BEGIN_NAMESPACE
1.62 -// swap and iter_swap
1.63 -template <class _Tp>
1.64 -inline void swap(_Tp& __a, _Tp& __b) {
1.65 - _Tp __tmp = __a;
1.66 - __a = __b;
1.67 - __b = __tmp;
1.68 -}
1.69 -
1.70 -template <class _ForwardIter1, class _ForwardIter2>
1.71 -inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) {
1.72 - swap(*__i1, *__i2);
1.73 -}
1.74 -
1.75 -//--------------------------------------------------
1.76 -// min and max
1.77 -
1.78 -# if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE)
1.79 -template <class _Tp>
1.80 -inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; }
1.81 -template <class _Tp>
1.82 -inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) { return __a < __b ? __b : __a; }
1.83 -#endif /* __BORLANDC__ */
1.84 -
1.85 -# if defined (__BORLANDC__) && ( __BORLANDC__ < 0x530 || defined (_STLP_USE_OWN_NAMESPACE))
1.86 -inline unsigned long (min) (unsigned long __a, unsigned long __b) { return __b < __a ? __b : __a; }
1.87 -inline unsigned long (max) (unsigned long __a, unsigned long __b) { return __a < __b ? __b : __a; }
1.88 -# endif
1.89 -
1.90 -template <class _Tp, class _Compare>
1.91 -inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
1.92 - return __comp(__b, __a) ? __b : __a;
1.93 -}
1.94 -
1.95 -template <class _Tp, class _Compare>
1.96 -inline const _Tp& (max)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
1.97 - return __comp(__a, __b) ? __b : __a;
1.98 -}
1.99 -
1.100 -//--------------------------------------------------
1.101 -// copy
1.102 -
1.103 -// All of these auxiliary functions serve two purposes. (1) Replace
1.104 -// calls to copy with memmove whenever possible. (Memmove, not memcpy,
1.105 -// because the input and output ranges are permitted to overlap.)
1.106 -// (2) If we're using random access iterators, then write the loop as
1.107 -// a for loop with an explicit count.
1.108 -
1.109 -template <class _InputIter, class _OutputIter, class _Distance>
1.110 -inline _OutputIter __copy(_InputIter __first, _InputIter __last,
1.111 - _OutputIter __result,
1.112 - const input_iterator_tag &, _Distance*) {
1.113 - for ( ; __first != __last; ++__result, ++__first)
1.114 - *__result = *__first;
1.115 - return __result;
1.116 -}
1.117 -
1.118 -# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.119 -template <class _InputIter, class _OutputIter, class _Distance>
1.120 -inline _OutputIter __copy(_InputIter __first, _InputIter __last,
1.121 - _OutputIter __result, const forward_iterator_tag &, _Distance* ) {
1.122 - for ( ; __first != __last; ++__result, ++__first)
1.123 - *__result = *__first;
1.124 - return __result;
1.125 -}
1.126 -
1.127 -
1.128 -template <class _InputIter, class _OutputIter, class _Distance>
1.129 -inline _OutputIter __copy(_InputIter __first, _InputIter __last,
1.130 - _OutputIter __result, const bidirectional_iterator_tag &, _Distance* __dis) {
1.131 - for ( ; __first != __last; ++__result, ++__first)
1.132 - *__result = *__first;
1.133 - return __result;
1.134 -}
1.135 -# endif
1.136 -
1.137 -template <class _RandomAccessIter, class _OutputIter, class _Distance>
1.138 -inline _OutputIter
1.139 -__copy(_RandomAccessIter __first, _RandomAccessIter __last,
1.140 - _OutputIter __result, const random_access_iterator_tag &, _Distance*) {
1.141 - for (_Distance __n = __last - __first; __n > 0; --__n) {
1.142 - *__result = *__first;
1.143 - ++__first;
1.144 - ++__result;
1.145 - }
1.146 - return __result;
1.147 -}
1.148 -
1.149 -inline void*
1.150 -__copy_trivial(const void* __first, const void* __last, void* __result) {
1.151 - return (__last == __first) ? __result :
1.152 - ((char*)memmove(__result, __first, ((const char*)__last - (const char*)__first))) +
1.153 - ((const char*)__last - (const char*)__first);
1.154 -}
1.155 -
1.156 -//--------------------------------------------------
1.157 -// copy_backward auxiliary functions
1.158 -
1.159 -template <class _BidirectionalIter1, class _BidirectionalIter2,
1.160 - class _Distance>
1.161 -inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
1.162 - _BidirectionalIter1 __last,
1.163 - _BidirectionalIter2 __result,
1.164 - const bidirectional_iterator_tag &,
1.165 - _Distance*)
1.166 -{
1.167 - while (__first != __last)
1.168 - *--__result = *--__last;
1.169 - return __result;
1.170 -}
1.171 -
1.172 -template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
1.173 -inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
1.174 - _RandomAccessIter __last,
1.175 - _BidirectionalIter __result,
1.176 - const random_access_iterator_tag &,
1.177 - _Distance*)
1.178 -{
1.179 - for (_Distance __n = __last - __first; __n > 0; --__n)
1.180 - *--__result = *--__last;
1.181 - return __result;
1.182 -}
1.183 -
1.184 -inline void*
1.185 -__copy_trivial_backward(const void* __first, const void* __last, void* __result) {
1.186 - const ptrdiff_t _Num = (const char*)__last - (const char*)__first;
1.187 - return (_Num > 0) ? memmove((char*)__result - _Num, __first, _Num) : __result ;
1.188 -}
1.189 -
1.190 -template <class _InputIter, class _OutputIter>
1.191 -inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.192 - return __copy(__first, __last, __result,
1.193 - _STLP_ITERATOR_CATEGORY(__first, _InputIter),
1.194 - _STLP_DISTANCE_TYPE(__first, _InputIter));
1.195 -}
1.196 -template <class _InputIter, class _OutputIter>
1.197 -inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.198 -// we know they all pointers, so this cast is OK
1.199 - // return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result));
1.200 - return (_OutputIter)__copy_trivial(__first, __last, __result);
1.201 -}
1.202 -
1.203 -template <class _InputIter, class _OutputIter>
1.204 -inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.205 - return __copy_ptrs(__first, __last, __result,
1.206 - _IsOKToMemCpy(_STLP_VALUE_TYPE(__first, _InputIter),
1.207 - _STLP_VALUE_TYPE(__result, _OutputIter))._Ret());
1.208 -}
1.209 -
1.210 -template <class _InputIter, class _OutputIter>
1.211 -inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.212 - return __copy(__first, __last, __result,
1.213 - _STLP_ITERATOR_CATEGORY(__first, _InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
1.214 -}
1.215 -
1.216 -template <class _InputIter, class _OutputIter>
1.217 -inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) {
1.218 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.219 - return __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter> :: _Ret());
1.220 -}
1.221 -
1.222 -template <class _InputIter, class _OutputIter>
1.223 -inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.224 - return __copy_backward(__first, __last, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
1.225 -}
1.226 -template <class _InputIter, class _OutputIter>
1.227 -inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.228 - return (_OutputIter)__copy_trivial_backward(__first, __last, __result);
1.229 -}
1.230 -
1.231 -template <class _InputIter, class _OutputIter>
1.232 -inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
1.233 - return __copy_backward(__first, __last, __result, _STLP_ITERATOR_CATEGORY(__first,_InputIter), _STLP_DISTANCE_TYPE(__first, _InputIter));
1.234 -}
1.235 -
1.236 -template <class _InputIter, class _OutputIter>
1.237 -inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
1.238 - return __copy_backward_ptrs(__first, __last, __result,
1.239 - _IsOKToMemCpy(_STLP_VALUE_TYPE(__first, _InputIter),
1.240 - _STLP_VALUE_TYPE(__result, _OutputIter))._Ret());
1.241 -}
1.242 -
1.243 -template <class _InputIter, class _OutputIter>
1.244 -inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) {
1.245 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.246 - return __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter> :: _Ret() );
1.247 -}
1.248 -
1.249 -#if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined ( _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS )
1.250 -#define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \
1.251 -inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \
1.252 -{ return (_Tp*)__copy_trivial(__first, __last, __result); } \
1.253 -inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \
1.254 -{ return (_Tp*)__copy_trivial_backward(__first, __last, __result); }
1.255 -
1.256 -_STLP_DECLARE_COPY_TRIVIAL(char)
1.257 -# ifndef _STLP_NO_SIGNED_BUILTINS
1.258 -_STLP_DECLARE_COPY_TRIVIAL(signed char)
1.259 -# endif
1.260 -_STLP_DECLARE_COPY_TRIVIAL(unsigned char)
1.261 -_STLP_DECLARE_COPY_TRIVIAL(short)
1.262 -_STLP_DECLARE_COPY_TRIVIAL(unsigned short)
1.263 -_STLP_DECLARE_COPY_TRIVIAL(int)
1.264 -_STLP_DECLARE_COPY_TRIVIAL(unsigned int)
1.265 -_STLP_DECLARE_COPY_TRIVIAL(long)
1.266 -_STLP_DECLARE_COPY_TRIVIAL(unsigned long)
1.267 -#if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT)
1.268 -_STLP_DECLARE_COPY_TRIVIAL(wchar_t)
1.269 -#endif
1.270 -#ifdef _STLP_LONG_LONG
1.271 -_STLP_DECLARE_COPY_TRIVIAL(long long)
1.272 -_STLP_DECLARE_COPY_TRIVIAL(unsigned long long)
1.273 -#endif
1.274 -_STLP_DECLARE_COPY_TRIVIAL(float)
1.275 -_STLP_DECLARE_COPY_TRIVIAL(double)
1.276 -# ifndef _STLP_NO_LONG_DOUBLE
1.277 -_STLP_DECLARE_COPY_TRIVIAL(long double)
1.278 -# endif
1.279 -#undef _STLP_DECLARE_COPY_TRIVIAL
1.280 -#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
1.281 -
1.282 -//--------------------------------------------------
1.283 -// copy_n (not part of the C++ standard)
1.284 -
1.285 -template <class _InputIter, class _Size, class _OutputIter>
1.286 -_STLP_INLINE_LOOP
1.287 -pair<_InputIter, _OutputIter> __copy_n(_InputIter __first, _Size __count,
1.288 - _OutputIter __result,
1.289 - const input_iterator_tag &) {
1.290 - for ( ; __count > 0; --__count) {
1.291 - *__result = *__first;
1.292 - ++__first;
1.293 - ++__result;
1.294 - }
1.295 - return pair<_InputIter, _OutputIter>(__first, __result);
1.296 -}
1.297 -
1.298 -template <class _RAIter, class _Size, class _OutputIter>
1.299 -inline pair<_RAIter, _OutputIter>
1.300 -__copy_n(_RAIter __first, _Size __count,
1.301 - _OutputIter __result,
1.302 - const random_access_iterator_tag &) {
1.303 - _RAIter __last = __first + __count;
1.304 - return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
1.305 -}
1.306 -
1.307 -template <class _InputIter, class _Size, class _OutputIter>
1.308 -inline pair<_InputIter, _OutputIter>
1.309 -__copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
1.310 - _STLP_FIX_LITERAL_BUG(__first)
1.311 - return __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
1.312 -}
1.313 -
1.314 -template <class _InputIter, class _Size, class _OutputIter>
1.315 -inline pair<_InputIter, _OutputIter>
1.316 -copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
1.317 - _STLP_FIX_LITERAL_BUG(__first)
1.318 - return __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
1.319 -}
1.320 -
1.321 -//--------------------------------------------------
1.322 -// fill and fill_n
1.323 -
1.324 -
1.325 -template <class _ForwardIter, class _Tp>
1.326 -_STLP_INLINE_LOOP
1.327 -void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
1.328 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.329 - for ( ; __first != __last; ++__first)
1.330 - *__first = __val;
1.331 -}
1.332 -
1.333 -template <class _OutputIter, class _Size, class _Tp>
1.334 -_STLP_INLINE_LOOP
1.335 -_OutputIter fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
1.336 - _STLP_FIX_LITERAL_BUG(__first)
1.337 - for ( ; __n > 0; --__n, ++__first)
1.338 - *__first = __val;
1.339 - return __first;
1.340 -}
1.341 -
1.342 -
1.343 -// Specialization: for one-byte types we can use memset.
1.344 -
1.345 -inline void fill(unsigned char* __first, unsigned char* __last,
1.346 - const unsigned char& __val) {
1.347 - unsigned char __tmp = __val;
1.348 - memset(__first, __tmp, __last - __first);
1.349 -}
1.350 -# ifndef _STLP_NO_SIGNED_BUILTINS
1.351 -inline void fill(signed char* __first, signed char* __last,
1.352 - const signed char& __val) {
1.353 - signed char __tmp = __val;
1.354 - memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
1.355 -}
1.356 -# endif
1.357 -inline void fill(char* __first, char* __last, const char& __val) {
1.358 - char __tmp = __val;
1.359 - memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
1.360 -}
1.361 -
1.362 -#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
1.363 -
1.364 -template <class _Size>
1.365 -inline unsigned char* fill_n(unsigned char* __first, _Size __n,
1.366 - const unsigned char& __val) {
1.367 - fill(__first, __first + __n, __val);
1.368 - return __first + __n;
1.369 -}
1.370 -
1.371 -template <class _Size>
1.372 -inline signed char* fill_n(char* __first, _Size __n,
1.373 - const signed char& __val) {
1.374 - fill(__first, __first + __n, __val);
1.375 - return __first + __n;
1.376 -}
1.377 -
1.378 -template <class _Size>
1.379 -inline char* fill_n(char* __first, _Size __n, const char& __val) {
1.380 - fill(__first, __first + __n, __val);
1.381 - return __first + __n;
1.382 -}
1.383 -
1.384 -#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
1.385 -
1.386 -
1.387 -//--------------------------------------------------
1.388 -// equal and mismatch
1.389 -
1.390 -template <class _InputIter1, class _InputIter2>
1.391 -_STLP_INLINE_LOOP
1.392 -pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
1.393 - _InputIter1 __last1,
1.394 - _InputIter2 __first2) {
1.395 - _STLP_FIX_LITERAL_BUG(__first2)
1.396 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.397 - while (__first1 != __last1 && *__first1 == *__first2) {
1.398 - ++__first1;
1.399 - ++__first2;
1.400 - }
1.401 - return pair<_InputIter1, _InputIter2>(__first1, __first2);
1.402 -}
1.403 -
1.404 -template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
1.405 -_STLP_INLINE_LOOP
1.406 -pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
1.407 - _InputIter1 __last1,
1.408 - _InputIter2 __first2,
1.409 - _BinaryPredicate __binary_pred) {
1.410 - _STLP_FIX_LITERAL_BUG(__first2)
1.411 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.412 - while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
1.413 - ++__first1;
1.414 - ++__first2;
1.415 - }
1.416 - return pair<_InputIter1, _InputIter2>(__first1, __first2);
1.417 -}
1.418 -
1.419 -template <class _InputIter1, class _InputIter2>
1.420 -_STLP_INLINE_LOOP
1.421 -bool equal(_InputIter1 __first1, _InputIter1 __last1,
1.422 - _InputIter2 __first2) {
1.423 - _STLP_FIX_LITERAL_BUG(__first1) _STLP_FIX_LITERAL_BUG(__last1) _STLP_FIX_LITERAL_BUG(__first2)
1.424 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.425 - for ( ; __first1 != __last1; ++__first1, ++__first2)
1.426 - if (!(*__first1 == *__first2))
1.427 - return false;
1.428 - return true;
1.429 -}
1.430 -
1.431 -template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
1.432 -_STLP_INLINE_LOOP
1.433 -bool equal(_InputIter1 __first1, _InputIter1 __last1,
1.434 - _InputIter2 __first2, _BinaryPredicate __binary_pred) {
1.435 - _STLP_FIX_LITERAL_BUG(__first2)
1.436 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.437 - for ( ; __first1 != __last1; ++__first1, ++__first2)
1.438 - if (!__binary_pred(*__first1, *__first2))
1.439 - return false;
1.440 - return true;
1.441 -}
1.442 -
1.443 -//--------------------------------------------------
1.444 -// lexicographical_compare and lexicographical_compare_3way.
1.445 -// (the latter is not part of the C++ standard.)
1.446 -
1.447 -template <class _InputIter1, class _InputIter2>
1.448 -bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
1.449 - _InputIter2 __first2, _InputIter2 __last2);
1.450 -
1.451 -template <class _InputIter1, class _InputIter2, class _Compare>
1.452 -bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
1.453 - _InputIter2 __first2, _InputIter2 __last2,
1.454 - _Compare __comp);
1.455 -
1.456 -inline bool
1.457 -lexicographical_compare(const unsigned char* __first1,
1.458 - const unsigned char* __last1,
1.459 - const unsigned char* __first2,
1.460 - const unsigned char* __last2)
1.461 -{
1.462 - const size_t __len1 = __last1 - __first1;
1.463 - const size_t __len2 = __last2 - __first2;
1.464 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.465 - _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
1.466 -
1.467 - const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
1.468 - return __result != 0 ? (__result < 0) : (__len1 < __len2);
1.469 -}
1.470 -
1.471 -
1.472 -# if !(CHAR_MAX == SCHAR_MAX)
1.473 -inline bool lexicographical_compare(const char* __first1, const char* __last1,
1.474 - const char* __first2, const char* __last2)
1.475 -{
1.476 - _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.477 - _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
1.478 -
1.479 - return lexicographical_compare((const unsigned char*) __first1,
1.480 - (const unsigned char*) __last1,
1.481 - (const unsigned char*) __first2,
1.482 - (const unsigned char*) __last2);
1.483 -}
1.484 -#endif /* CHAR_MAX == SCHAR_MAX */
1.485 -
1.486 -template <class _InputIter1, class _InputIter2>
1.487 -int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
1.488 - _InputIter2 __first2, _InputIter2 __last2);
1.489 -
1.490 -inline int
1.491 -__lexicographical_compare_3way(const unsigned char* __first1,
1.492 - const unsigned char* __last1,
1.493 - const unsigned char* __first2,
1.494 - const unsigned char* __last2)
1.495 -{
1.496 - const ptrdiff_t __len1 = __last1 - __first1;
1.497 - const ptrdiff_t __len2 = __last2 - __first2;
1.498 - const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
1.499 - return __result != 0 ? __result
1.500 - : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
1.501 -}
1.502 -
1.503 -
1.504 -# if !(CHAR_MAX == SCHAR_MAX)
1.505 -inline int
1.506 -__lexicographical_compare_3way(const char* __first1, const char* __last1,
1.507 - const char* __first2, const char* __last2)
1.508 -{
1.509 - return __lexicographical_compare_3way((const unsigned char*) __first1,
1.510 - (const unsigned char*) __last1,
1.511 - (const unsigned char*) __first2,
1.512 - (const unsigned char*) __last2);
1.513 -}
1.514 -# endif
1.515 -
1.516 -# ifndef _STLP_NO_EXTENSIONS
1.517 -
1.518 -template <class _InputIter1, class _InputIter2>
1.519 -int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
1.520 - _InputIter2 __first2, _InputIter2 __last2);
1.521 -
1.522 -# endif /* EXTENSIONS */
1.523 -
1.524 -// count
1.525 -template <class _InputIter, class _Tp>
1.526 -_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
1.527 -count(_InputIter __first, _InputIter __last, const _Tp& __val) {
1.528 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.529 - _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
1.530 - for ( ; __first != __last; ++__first)
1.531 - if (*__first == __val)
1.532 - ++__n;
1.533 - return __n;
1.534 -}
1.535 -
1.536 -// find and find_if. Note find may be expressed in terms of find_if if appropriate binder was available.
1.537 -template <class _InputIter, class _Tp>
1.538 -_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val);
1.539 -template <class _InputIter, class _Predicate>
1.540 -_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred);
1.541 -
1.542 -// search.
1.543 -template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>
1.544 -_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
1.545 - _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate);
1.546 -
1.547 -// find_first_of
1.548 -template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
1.549 -_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
1.550 - _ForwardIter __first2, _ForwardIter __last2,
1.551 - _BinaryPredicate __comp);
1.552 -
1.553 -template <class _ForwardIter1, class _ForwardIter2,
1.554 - class _BinaryPredicate>
1.555 -_ForwardIter1
1.556 -find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
1.557 - _ForwardIter2 __first2, _ForwardIter2 __last2,
1.558 - _BinaryPredicate __comp);
1.559 -
1.560 -// replace
1.561 -template <class _ForwardIter, class _Tp>
1.562 -_STLP_INLINE_LOOP void
1.563 -replace(_ForwardIter __first, _ForwardIter __last,
1.564 - const _Tp& __old_value, const _Tp& __new_value) {
1.565 - _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.566 - for ( ; __first != __last; ++__first)
1.567 - if (*__first == __old_value)
1.568 - *__first = __new_value;
1.569 -}
1.570 -
1.571 -template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
1.572 -_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
1.573 - const _Tp& __val, _Compare __comp, _Distance*);
1.574 -
1.575 -_STLP_END_NAMESPACE
1.576 -
1.577 -# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.578 -# include <stl/_algobase.c>
1.579 -# endif
1.580 -
1.581 -#endif /* _STLP_INTERNAL_ALGOBASE_H */
1.582 -
1.583 -// Local Variables:
1.584 -// mode:C++
1.585 -// End:
1.586 -