epoc32/include/stdapis/stlport/stl/_algo.c
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h) This is the epoc32/include tree with the "platform" subtrees removed, and all but a selected few mbg and rsg files removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
/*
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
 * Copyright (c) 1994
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
 * Hewlett-Packard Company
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
 * Copyright (c) 1996,1997
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
 * Silicon Graphics Computer Systems, Inc.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
 * Copyright (c) 1997
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
 * Moscow Center for SPARC Technology
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
 * Copyright (c) 1999 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
 * Boris Fomitchev
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
 * This material is provided "as is", with absolutely no warranty expressed
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
 * or implied. Any use is at your own risk.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
 * Permission to use or copy this software for any purpose is hereby granted 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
 * without fee, provided the above notices are retained on all copies.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
 * Permission to modify the code and to distribute modified code is granted,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
 * provided the above notices are retained, and a notice that the code was
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
 * modified is included with the above copyright notice.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
 *
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    24
 */
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    26
#ifndef _STLP_ALGO_C
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    27
# define _STLP_ALGO_C
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    28
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    29
# if !defined (_STLP_INTERNAL_ALGO_H)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    30
#  include <stl/_algo.h>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    31
# endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    32
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    33
_STLP_BEGIN_NAMESPACE
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    34
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
template <class _BidirectionalIter, class _Distance, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
void __merge_without_buffer(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
                            _BidirectionalIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
                            _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
                            _Distance __len1, _Distance __len2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
                            _Compare __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    42
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
template <class _BidirectionalIter1, class _BidirectionalIter2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
          class _BidirectionalIter3, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
                                     _BidirectionalIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
                                     _BidirectionalIter2 __first2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
                                     _BidirectionalIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
                                     _BidirectionalIter3 __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
                                     _Compare __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    51
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
template <class _Tp>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
# if !(defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x420 ))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    54
inline 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    55
# endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    57
  if (__a < __b)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    58
    if (__b < __c)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    59
      return __b;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    60
    else if (__a < __c)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    61
      return __c;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    62
    else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    63
      return __a;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    64
  else if (__a < __c)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
    return __a;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
  else if (__b < __c)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
    return __c;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    68
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    69
    return __b;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    70
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    71
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    72
template <class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    73
# if !(defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x420 ))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    74
inline 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    75
# endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    76
const _Tp&
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    77
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
  if (__comp(__a, __b))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    79
    if (__comp(__b, __c))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    80
      return __b;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    81
    else if (__comp(__a, __c))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    82
      return __c;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    83
    else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    84
      return __a;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
  else if (__comp(__a, __c))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    86
    return __a;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    87
  else if (__comp(__b, __c))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    88
    return __c;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    89
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    90
    return __b;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    92
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
template <class _ForwardIter1, class _ForwardIter2>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
                     _ForwardIter2 __first2, _ForwardIter2 __last2) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
  // Test for empty ranges
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
  if (__first1 == __last1 || __first2 == __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   101
    return __first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   102
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   103
  // Test for a pattern of length 1.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
  _ForwardIter2 __tmp(__first2);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
  ++__tmp;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   106
  if (__tmp == __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
    return find(__first1, __last1, *__first2);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
  // General case.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
  _ForwardIter2 __p1 = __first2; 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   111
  ++__p1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
  _ForwardIter1 __current = __first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   115
  while (__first1 != __last1) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
    __first1 = find(__first1, __last1, *__first2);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
    if (__first1 == __last1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   118
      return __last1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   119
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   120
    _ForwardIter2 __p = __p1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   121
    __current = __first1; 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   122
    if (++__current == __last1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   123
      return __last1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   124
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   125
    while (*__current == *__p) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   126
      if (++__p == __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   127
        return __first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   128
      if (++__current == __last1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   129
        return __last1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   130
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   131
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   132
    ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   133
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   134
  return __first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   135
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   136
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   137
// search_n.  Search for __count consecutive copies of __val.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   138
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   139
template <class _ForwardIter, class _Integer, class _Tp>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   140
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   141
                      _Integer __count, const _Tp& __val) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   142
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   143
  if (__count <= 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   144
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   145
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   146
    __first = find(__first, __last, __val);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   147
    while (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   148
      _Integer __n = __count - 1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   149
      _ForwardIter __i = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   150
      ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   151
      while (__i != __last && __n != 0 && *__i == __val) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   152
        ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   153
        --__n;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   154
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   155
      if (__n == 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   156
        return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   157
      else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   158
        __first = find(__i, __last, __val);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   159
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   160
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   161
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   162
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   163
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   164
template <class _ForwardIter, class _Integer, class _Tp, class _BinaryPred>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   165
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   166
                      _Integer __count, const _Tp& __val,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   167
                      _BinaryPred __binary_pred) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   168
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   169
  if (__count <= 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   170
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   171
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   172
    while (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   173
      if (__binary_pred(*__first, __val))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   174
        break;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   175
      ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   176
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   177
    while (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   178
      _Integer __n = __count - 1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   179
      _ForwardIter __i = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   180
      ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   181
      while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   182
        ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   183
        --__n;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   184
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   185
      if (__n == 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   186
        return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   187
      else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   188
        while (__i != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   189
          if (__binary_pred(*__i, __val))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   190
            break;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   191
          ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   192
        }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   193
        __first = __i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   194
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   195
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   196
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   197
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   198
} 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   199
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   200
template <class _ForwardIter1, class _ForwardIter2>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   201
_ForwardIter1 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   202
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   203
         _ForwardIter2 __first2, _ForwardIter2 __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   204
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   205
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   206
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   207
  return __find_end(__first1, __last1, __first2, __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   208
# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   209
                    _STLP_ITERATOR_CATEGORY(__first1, _ForwardIter1),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   210
                    _STLP_ITERATOR_CATEGORY(__first2, _ForwardIter2),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   211
# else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   212
		    forward_iterator_tag(),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   213
                    forward_iterator_tag(),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   214
# endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   215
                    __equal_to(_STLP_VALUE_TYPE(__first1, _ForwardIter1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   216
    );
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   217
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   218
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   219
// unique and unique_copy
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   220
template <class _InputIterator, class _OutputIterator, class _BinaryPredicate,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   221
					    class _Tp>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   222
_STLP_INLINE_LOOP _OutputIterator 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   223
__unique_copy(_InputIterator __first, _InputIterator __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   224
              _OutputIterator __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   225
              _BinaryPredicate __binary_pred, _Tp*) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   226
  _Tp __val = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   227
 _STLP_PUSH_STACK_ITEM(_Tp, &__val)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   228
  *__result = __val;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   229
  while (++__first != __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   230
    if (!__binary_pred(__val, *__first)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   231
      __val = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   232
      *++__result = __val;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   233
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   234
  return ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   235
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   236
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   237
template <class _InputIter, class _OutputIter, class _BinaryPredicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   238
inline _OutputIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   239
__unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   240
              _BinaryPredicate __binary_pred, const output_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   241
  return __unique_copy(__first, __last, __result, __binary_pred, _STLP_VALUE_TYPE(__first, _InputIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   242
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   243
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   244
template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   245
_STLP_INLINE_LOOP _ForwardIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   246
__unique_copy(_InputIter __first, _InputIter __last, _ForwardIter __result, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   247
              _BinaryPredicate __binary_pred, const forward_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   248
  *__result = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   249
  while (++__first != __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   250
    if (!__binary_pred(*__result, *__first)) *++__result = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   251
  return ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   252
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   253
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   254
# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   255
template <class _InputIterator, class _BidirectionalIterator, class _BinaryPredicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   256
inline _BidirectionalIterator 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   257
__unique_copy(_InputIterator __first, _InputIterator __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   258
              _BidirectionalIterator __result, _BinaryPredicate __binary_pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   259
              const bidirectional_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   260
  return __unique_copy(__first, __last, __result, __binary_pred, forward_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   261
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   262
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   263
template <class _InputIterator, class _RandomAccessIterator, class _BinaryPredicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   264
inline _RandomAccessIterator 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   265
__unique_copy(_InputIterator __first, _InputIterator __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   266
              _RandomAccessIterator __result, _BinaryPredicate __binary_pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   267
              const random_access_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   268
  return __unique_copy(__first, __last, __result, __binary_pred, forward_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   269
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   270
# endif /* _STLP_NONTEMPL_BASE_MATCH_BUG */
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   271
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   272
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   273
template <class _InputIter, class _OutputIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   274
_OutputIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   275
unique_copy(_InputIter __first, _InputIter __last, _OutputIter __result) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   276
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   277
  if (__first == __last) return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   278
  return __unique_copy(__first, __last, __result, __equal_to(_STLP_VALUE_TYPE(__first, _InputIter)),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   279
                       _STLP_ITERATOR_CATEGORY(__result, _OutputIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   280
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   281
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   282
template <class _InputIter, class _OutputIter, class _BinaryPredicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   283
_OutputIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   284
unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   285
            _BinaryPredicate __binary_pred) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   286
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   287
  if (__first == __last) return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   288
  return __unique_copy(__first, __last, __result, __binary_pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   289
                       _STLP_ITERATOR_CATEGORY(__result, _OutputIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   290
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   291
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   292
// rotate and rotate_copy, and their auxiliary functions
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   293
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   294
template <class _ForwardIter, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   295
_ForwardIter __rotate(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   296
                      _ForwardIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   297
                      _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   298
                      _Distance*,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   299
                      const forward_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   300
  if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   301
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   302
  if (__last  == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   303
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   304
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   305
  _ForwardIter __first2 = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   306
  do {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   307
    swap(*__first++, *__first2++);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   308
    if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   309
      __middle = __first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   310
  } while (__first2 != __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   311
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   312
  _ForwardIter __new_middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   313
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   314
  __first2 = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   315
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   316
  while (__first2 != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   317
    swap (*__first++, *__first2++);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   318
    if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   319
      __middle = __first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   320
    else if (__first2 == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   321
      __first2 = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   322
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   323
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   324
  return __new_middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   325
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   326
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   327
template <class _BidirectionalIter, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   328
_BidirectionalIter __rotate(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   329
                            _BidirectionalIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   330
                            _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   331
                            _Distance*,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   332
                            const bidirectional_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   333
  if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   334
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   335
  if (__last  == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   336
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   337
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   338
  __reverse(__first,  __middle, bidirectional_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   339
  __reverse(__middle, __last,   bidirectional_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   340
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   341
  while (__first != __middle && __middle != __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   342
    swap (*__first++, *--__last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   343
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   344
  if (__first == __middle) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   345
    __reverse(__middle, __last,   bidirectional_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   346
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   347
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   348
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   349
    __reverse(__first,  __middle, bidirectional_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   350
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   351
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   352
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   353
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   354
template <class _RandomAccessIter, class _Distance, class _Tp>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   355
_RandomAccessIter __rotate(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   356
                           _RandomAccessIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   357
                           _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   358
                           _Distance *, _Tp *) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   359
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   360
  _Distance __n = __last   - __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   361
  _Distance __k = __middle - __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   362
  _Distance __l = __n - __k;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   363
  _RandomAccessIter __result = __first + (__last - __middle);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   364
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   365
  if (__k==0)  /* __first == middle */
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   366
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   367
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   368
  if (__k == __l) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   369
    swap_ranges(__first, __middle, __middle);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   370
    return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   371
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   372
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   373
  _Distance __d = __gcd(__n, __k);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   374
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   375
  for (_Distance __i = 0; __i < __d; __i++) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   376
    _Tp __tmp = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   377
    _STLP_PUSH_STACK_ITEM(_Tp, &__tmp)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   378
    _RandomAccessIter __p = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   379
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   380
    if (__k < __l) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   381
      for (_Distance __j = 0; __j < __l/__d; __j++) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   382
	if (__p > __first + __l) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   383
          *__p = *(__p - __l);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   384
          __p -= __l;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   385
        }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   386
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   387
        *__p = *(__p + __k);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   388
        __p += __k;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   389
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   390
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   391
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   392
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   393
      for (_Distance __j = 0; __j < __k/__d - 1; __j ++) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   394
        if (__p < __last - __k) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   395
          *__p = *(__p + __k);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   396
          __p += __k;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   397
        }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   398
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   399
        *__p = * (__p - __l);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   400
        __p -= __l;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   401
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   402
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   403
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   404
    *__p = __tmp;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   405
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   406
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   407
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   408
  return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   409
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   410
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   411
template <class _RandomAccessIter, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   412
inline _RandomAccessIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   413
__rotate(_RandomAccessIter __first, _RandomAccessIter __middle, _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   414
         _Distance * __dis, const random_access_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   415
  return __rotate(__first, __middle, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   416
                  __dis, _STLP_VALUE_TYPE(__first, _RandomAccessIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   417
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   418
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   419
template <class _ForwardIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   420
_ForwardIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   421
rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   422
  _STLP_DEBUG_CHECK(__check_range(__first, __middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   423
  _STLP_DEBUG_CHECK(__check_range(__middle, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   424
  return __rotate(__first, __middle, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   425
                  _STLP_DISTANCE_TYPE(__first, _ForwardIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   426
                  _STLP_ITERATOR_CATEGORY(__first, _ForwardIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   427
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   428
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   429
// Return a random number in the range [0, __n).  This function encapsulates
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   430
// whether we're using rand (part of the standard C library) or lrand48
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   431
// (not standard, but a much better choice whenever it's available).
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   432
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   433
template <class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   434
inline _Distance __random_number(_Distance __n) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   435
#ifdef _STLP_NO_DRAND48
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   436
  return rand() % __n;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   437
#else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   438
  return lrand48() % __n;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   439
#endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   440
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   441
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   442
template <class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   443
void random_shuffle(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   444
		    _RandomAccessIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   445
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   446
  if (__first == __last) return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   447
  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   448
    iter_swap(__i, __first + __random_number((__i - __first) + 1));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   449
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   450
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   451
template <class _RandomAccessIter, class _RandomNumberGenerator>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   452
void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   453
                    _RandomNumberGenerator& __rand) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   454
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   455
  if (__first == __last) return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   456
  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   457
    iter_swap(__i, __first + __rand((__i - __first) + 1));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   458
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   459
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   460
# ifndef _STLP_NO_EXTENSIONS
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   461
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   462
// random_sample and random_sample_n (extensions, not part of the standard).
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   463
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   464
template <class _ForwardIter, class _OutputIter, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   465
_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   466
                            _OutputIter __stl_out, const _Distance __n)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   467
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   468
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   469
  _Distance __remaining = distance(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   470
  _Distance __m = (min) (__n, __remaining);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   471
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   472
  while (__m > 0) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   473
    if (__random_number(__remaining) < __m) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   474
      *__stl_out = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   475
      ++__stl_out;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   476
      --__m;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   477
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   478
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   479
    --__remaining;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   480
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   481
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   482
  return __stl_out;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   483
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   484
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   485
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   486
template <class _ForwardIter, class _OutputIter, class _Distance,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   487
          class _RandomNumberGenerator>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   488
_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   489
                            _OutputIter __stl_out, const _Distance __n,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   490
                            _RandomNumberGenerator& __rand)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   491
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   492
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   493
  _Distance __remaining = distance(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   494
  _Distance __m = (min) (__n, __remaining);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   495
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   496
  while (__m > 0) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   497
    if (__rand(__remaining) < __m) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   498
      *__stl_out = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   499
      ++__stl_out;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   500
      --__m;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   501
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   502
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   503
    --__remaining;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   504
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   505
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   506
  return __stl_out;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   507
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   508
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   509
template <class _InputIter, class _RandomAccessIter, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   510
_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   511
                                  _RandomAccessIter __stl_out,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   512
                                  const _Distance __n)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   513
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   514
  _Distance __m = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   515
  _Distance __t = __n;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   516
  for ( ; __first != __last && __m < __n; ++__m, ++__first) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   517
    __stl_out[__m] = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   518
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   519
  while (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   520
    ++__t;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   521
    _Distance __M = __random_number(__t);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   522
    if (__M < __n)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   523
      __stl_out[__M] = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   524
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   525
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   526
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   527
  return __stl_out + __m;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   528
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   529
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   530
template <class _InputIter, class _RandomAccessIter,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   531
          class _RandomNumberGenerator, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   532
_RandomAccessIter __random_sample(_InputIter __first, _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   533
                                  _RandomAccessIter __stl_out,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   534
                                  _RandomNumberGenerator& __rand,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   535
                                  const _Distance __n)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   536
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   537
  _Distance __m = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   538
  _Distance __t = __n;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   539
  for ( ; __first != __last && __m < __n; ++__m, ++__first)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   540
    __stl_out[__m] = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   541
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   542
  while (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   543
    ++__t;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   544
    _Distance __M = __rand(__t);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   545
    if (__M < __n)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   546
      __stl_out[__M] = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   547
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   548
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   549
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   550
  return __stl_out + __m;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   551
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   552
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   553
template <class _InputIter, class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   554
_RandomAccessIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   555
random_sample(_InputIter __first, _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   556
              _RandomAccessIter __out_first, _RandomAccessIter __out_last) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   557
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   558
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   559
  _STLP_DEBUG_CHECK(__check_range(__out_first, __out_last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   560
  return __random_sample(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   561
                         __out_first, __out_last - __out_first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   562
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   563
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   564
template <class _InputIter, class _RandomAccessIter, class _RandomNumberGenerator>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   565
_RandomAccessIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   566
random_sample(_InputIter __first, _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   567
              _RandomAccessIter __out_first, _RandomAccessIter __out_last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   568
              _RandomNumberGenerator& __rand) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   569
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   570
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   571
  _STLP_DEBUG_CHECK(__check_range(__out_first, __out_last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   572
  return __random_sample(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   573
                         __out_first, __rand,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   574
                         __out_last - __out_first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   575
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   576
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   577
# endif /* _STLP_NO_EXTENSIONS */
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   578
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   579
// partition, stable_partition, and their auxiliary functions
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   580
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   581
template <class _ForwardIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   582
_STLP_INLINE_LOOP _ForwardIter __partition(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   583
                                           _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   584
                                           _Predicate   __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   585
                                           const forward_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   586
  if (__first == __last) return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   587
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   588
  while (__pred(*__first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   589
    if (++__first == __last) return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   590
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   591
  _ForwardIter __next = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   592
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   593
  while (++__next != __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   594
    if (__pred(*__next)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   595
      swap(*__first, *__next);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   596
      ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   597
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   598
  return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   599
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   600
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   601
/* bug fix- start*/
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   602
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   603
template <class _ForwardIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   604
_ForwardIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   605
__rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   606
  _STLP_DEBUG_CHECK(__check_range(__first, __middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   607
  _STLP_DEBUG_CHECK(__check_range(__middle, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   608
  return __rotate_aux(__first, __middle, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   609
                      _STLP_DISTANCE_TYPE(__first, _ForwardIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   610
                      _STLP_ITERATOR_CATEGORY(__first, _ForwardIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   611
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   612
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   613
template <class _ForwardIter, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   614
_ForwardIter __rotate_aux(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   615
                          _ForwardIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   616
                          _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   617
                          _Distance*,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   618
                          const forward_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   619
  if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   620
    return __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   621
  if (__last  == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   622
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   623
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   624
  _ForwardIter __first2 = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   625
  do {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   626
    swap(*__first++, *__first2++);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   627
    if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   628
      __middle = __first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   629
  } while (__first2 != __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   630
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   631
  _ForwardIter __new_middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   632
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   633
  __first2 = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   634
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   635
  while (__first2 != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   636
    swap (*__first++, *__first2++);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   637
    if (__first == __middle)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   638
      __middle = __first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   639
    else if (__first2 == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   640
      __first2 = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   641
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   642
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   643
  return __new_middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   644
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   645
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   646
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   647
template <class _ForwardIter, class _Pointer, class _Predicate,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   648
          class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   649
_ForwardIter __stable_partition_adaptive(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   650
                                         _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   651
                                         _Predicate __pred, _Distance __len,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   652
                                         _Pointer __buffer, _Distance __buffer_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   653
                                         bool __pred_of_first, bool __pred_of_before_last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   654
  if (__len <= __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   655
    _ForwardIter __result1 = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   656
    _Pointer __result2 = __buffer;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   657
    if ((__first != __last) && (!__pred_of_first || __pred(*__first))) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   658
      *__result2 = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   659
      ++__result2; ++__first; --__len;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   660
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   661
    for (; __first != __last ; ++__first, --__len) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   662
      if (((__len == 1) && (__pred_of_before_last || __pred(*__first))) ||
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   663
          ((__len != 1) && __pred(*__first))){
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   664
        *__result1 = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   665
        ++__result1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   666
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   667
      else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   668
        *__result2 = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   669
        ++__result2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   670
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   671
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   672
    copy(__buffer, __result2, __result1);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   673
    return __result1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   674
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   675
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   676
    _ForwardIter __middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   677
    _Distance __half_len = __len / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   678
    advance(__middle, __half_len);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   679
    return __rotate(__stable_partition_adaptive(
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   680
                          __first, __middle, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   681
                          __half_len, __buffer, __buffer_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   682
                          __pred_of_first, false),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   683
                    __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   684
                    __stable_partition_adaptive(
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   685
                          __middle, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   686
                          __len - __half_len, __buffer, __buffer_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   687
                          true, __pred_of_before_last));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   688
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   689
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   690
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   691
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   692
template <class _ForwardIter, class _Predicate, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   693
_ForwardIter __inplace_stable_partition(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   694
                                        _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   695
                                        _Predicate __pred, _Distance __len,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   696
                                        bool __pred_of_first, bool __pred_of_before_last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   697
  if (__len == 1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   698
    return (__pred_of_first && (__pred_of_before_last || __pred(*__first))) ? __last : __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   699
  _ForwardIter __middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   700
  _Distance __half_len = __len / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   701
  advance(__middle, __half_len);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   702
  return __rotate(__inplace_stable_partition(__first, __middle, __pred, __half_len, __pred_of_first, false),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   703
                  __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   704
                  __inplace_stable_partition(__middle, __last, __pred, __len - __half_len, true, __pred_of_before_last));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   705
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   706
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   707
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   708
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   709
template <class _ForwardIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   710
_ForwardIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   711
stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   712
  _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   713
  for (;;) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   714
    if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   715
      return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   716
    else if (__pred(*__first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   717
      ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   718
    else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   719
      break;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   720
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   721
  return  __stable_partition_aux(__first, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   722
                                           _STLP_ITERATOR_CATEGORY(__first, _ForwardIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   723
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   724
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   725
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   726
template <class _ForwardIter, class _Predicate, class _Tp, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   727
inline _ForwardIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   728
__stable_partition_aux_aux(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   729
                           _Predicate __pred, _Tp*, _Distance*, bool __pred_of_before_last = false) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   730
  _Temporary_buffer<_ForwardIter, _Tp> __buf(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   731
  return (__buf.size() > 0) ?
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   732
    __stable_partition_adaptive(__first, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   733
                                _Distance(__buf.requested_size()),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   734
                                __buf.begin(), __buf.size(),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   735
                                false, __pred_of_before_last)  :
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   736
    __inplace_stable_partition(__first, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   737
                               _Distance(__buf.requested_size()),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   738
                               false, __pred_of_before_last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   739
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   740
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   741
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   742
template <class _ForwardIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   743
_ForwardIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   744
__stable_partition_aux(_ForwardIter __first, _ForwardIter __last, _Predicate __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   745
                       const forward_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   746
  return __stable_partition_aux_aux(__first, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   747
                                    _STLP_VALUE_TYPE(__first, _ForwardIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   748
                                    _STLP_DISTANCE_TYPE(__first, _ForwardIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   749
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   750
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   751
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   752
/* bug fix- end*/
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   753
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   754
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   755
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   756
template <class _BidirectionalIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   757
_STLP_INLINE_LOOP _BidirectionalIter __partition(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   758
                                                 _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   759
                                                 _Predicate __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   760
                                                 const bidirectional_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   761
  while (true) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   762
    while (true)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   763
      if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   764
        return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   765
      else if (__pred(*__first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   766
        ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   767
      else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   768
        break;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   769
    --__last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   770
    while (true)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   771
      if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   772
        return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   773
      else if (!__pred(*__last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   774
        --__last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   775
      else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   776
        break;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   777
    iter_swap(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   778
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   779
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   780
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   781
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   782
# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   783
template <class _BidirectionalIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   784
inline
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   785
_BidirectionalIter __partition(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   786
                               _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   787
			       _Predicate __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   788
			       const random_access_iterator_tag &) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   789
  return __partition(__first, __last, __pred, bidirectional_iterator_tag());
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   790
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   791
# endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   792
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   793
template <class _ForwardIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   794
_ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate   __pred) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   795
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   796
  return __partition(__first, __last, __pred, _STLP_ITERATOR_CATEGORY(__first, _ForwardIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   797
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   798
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   799
/*
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   800
template <class _ForwardIter, class _Predicate, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   801
_ForwardIter __inplace_stable_partition(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   802
                                        _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   803
                                        _Predicate __pred, _Distance __len) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   804
  if (__len == 1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   805
    return __pred(*__first) ? __last : __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   806
  _ForwardIter __middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   807
  advance(__middle, __len / 2);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   808
  return rotate(__inplace_stable_partition(__first, __middle, __pred, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   809
                                           __len / 2),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   810
                __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   811
                __inplace_stable_partition(__middle, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   812
                                           __len - __len / 2));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   813
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   814
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   815
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   816
template <class _ForwardIter, class _Pointer, class _Predicate, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   817
          class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   818
_ForwardIter __stable_partition_adaptive(_ForwardIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   819
                                         _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   820
                                         _Predicate __pred, _Distance __len,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   821
                                         _Pointer __buffer,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   822
                                         _Distance __buffer_size) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   823
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   824
  if (__len <= __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   825
    _ForwardIter __result1 = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   826
    _Pointer __result2 = __buffer;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   827
    for ( ; __first != __last ; ++__first)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   828
      if (__pred(*__first)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   829
        *__result1 = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   830
        ++__result1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   831
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   832
      else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   833
        *__result2 = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   834
        ++__result2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   835
      }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   836
    copy(__buffer, __result2, __result1);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   837
    return __result1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   838
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   839
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   840
    _ForwardIter __middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   841
    advance(__middle, __len / 2);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   842
    return rotate(__stable_partition_adaptive(
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   843
                          __first, __middle, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   844
                          _Distance(__len / 2), __buffer, __buffer_size),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   845
                    __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   846
                    __stable_partition_adaptive(
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   847
                          __middle, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   848
                          _Distance(__len - __len / 2), __buffer, __buffer_size));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   849
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   850
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   851
*/ //bug fix
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   852
template <class _ForwardIter, class _Predicate, class _Tp, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   853
inline _ForwardIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   854
__stable_partition_aux(_ForwardIter __first, _ForwardIter __last, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   855
                       _Predicate __pred, _Tp*, _Distance*)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   856
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   857
  typedef _Temporary_buffer<_ForwardIter, _Tp> _TmpBuf;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   858
  _Temporary_buffer<_ForwardIter, _Tp> __buf(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   859
  _STLP_PUSH_STACK_ITEM(_TmpBuf, &__buf);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   860
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   861
  _STLP_MPWFIX_TRY		//*TY 06/01/2000 - they forget to call dtor for _Temporary_buffer if no try/catch block is present
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   862
  return (__buf.size() > 0) ?
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   863
    __stable_partition_adaptive(__first, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   864
				_Distance(__buf.requested_size()),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   865
				__buf.begin(), _Distance(__buf.size()))  :
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   866
    __inplace_stable_partition(__first, __last, __pred, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   867
			       _Distance(__buf.requested_size()));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   868
  _STLP_MPWFIX_CATCH	//*TY 06/01/2000 - they forget to call dtor for _Temporary_buffer if no try/catch block is present
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   869
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   870
/*
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   871
template <class _ForwardIter, class _Predicate>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   872
_ForwardIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   873
stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   874
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   875
  if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   876
    return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   877
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   878
    return __stable_partition_aux(__first, __last, __pred,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   879
                                  _STLP_VALUE_TYPE(__first, _ForwardIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   880
                                  _STLP_DISTANCE_TYPE(__first, _ForwardIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   881
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   882
*/ //bug fix
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   883
template <class _RandomAccessIter, class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   884
_RandomAccessIter __unguarded_partition(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   885
                                        _RandomAccessIter __last, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   886
                                        _Tp __pivot, _Compare __comp) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   887
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   888
  _STLP_PUSH_STACK_ITEM(_Tp, &__pivot)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   889
  while (true) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   890
    while (__comp(*__first, __pivot))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   891
      ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   892
    --__last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   893
    while (__comp(__pivot, *__last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   894
      --__last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   895
    if (!(__first < __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   896
      return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   897
    iter_swap(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   898
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   899
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   900
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   901
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   902
// sort() and its auxiliary functions. 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   903
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   904
# define  __stl_threshold  16
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   905
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   906
template <class _RandomAccessIter, class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   907
void __unguarded_linear_insert(_RandomAccessIter __last, _Tp __val, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   908
                               _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   909
   _STLP_PUSH_STACK_ITEM(_Tp, &__val)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   910
  _RandomAccessIter __next = __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   911
  --__next;  
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   912
  while (__comp(__val, *__next)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   913
    *__last = *__next;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   914
    __last = __next;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   915
    --__next;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   916
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   917
  *__last = __val;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   918
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   919
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   920
template <class _RandomAccessIter, class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   921
inline void __linear_insert(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   922
                            _RandomAccessIter __last, _Tp __val, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   923
  _STLP_PUSH_STACK_ITEM(_Tp, &__val)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   924
  if (__comp(__val, *__first)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   925
    copy_backward(__first, __last, __last + 1);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   926
    *__first = __val;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   927
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   928
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   929
    __unguarded_linear_insert(__last, __val, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   930
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   931
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   932
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   933
void __insertion_sort(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   934
                      _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   935
  if (__first == __last) return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   936
  for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   937
    __linear_insert(__first, __i, *__i, __comp);	//*TY 12/26/1998 - supply *__i as __val
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   938
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   939
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   940
template <class _RandomAccessIter, class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   941
void __unguarded_insertion_sort_aux(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   942
                                    _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   943
                                    _Tp*, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   944
  for (_RandomAccessIter __i = __first; __i != __last; ++__i)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   945
    __unguarded_linear_insert(__i, _Tp(*__i), __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   946
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   947
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   948
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   949
inline void __unguarded_insertion_sort(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   950
                                       _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   951
                                       _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   952
  __unguarded_insertion_sort_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   953
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   954
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   955
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   956
void __final_insertion_sort(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   957
                            _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   958
  if (__last - __first > __stl_threshold) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   959
    __insertion_sort(__first, __first + __stl_threshold, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   960
    __unguarded_insertion_sort(__first + __stl_threshold, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   961
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   962
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   963
    __insertion_sort(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   964
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   965
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   966
template <class _RandomAccessIter, class _Tp, class _Size, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   967
void __introsort_loop(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   968
                      _RandomAccessIter __last, _Tp*,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   969
                      _Size __depth_limit, _Compare __comp)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   970
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   971
  while (__last - __first > __stl_threshold) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   972
    if (__depth_limit == 0) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   973
      partial_sort(__first, __last, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   974
      return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   975
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   976
    --__depth_limit;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   977
    _RandomAccessIter __cut =
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   978
      __unguarded_partition(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   979
                            _Tp(__median(*__first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   980
                                         *(__first + (__last - __first)/2),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   981
                                         *(__last - 1), __comp)),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   982
       __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   983
    __introsort_loop(__cut, __last, (_Tp*) 0, __depth_limit, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   984
    __last = __cut;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   985
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   986
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   987
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   988
template <class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   989
void sort(_RandomAccessIter __first, _RandomAccessIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   990
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   991
  if (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   992
    __introsort_loop(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   993
                     _STLP_VALUE_TYPE(__first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   994
                     __lg(__last - __first) * 2, __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)) );
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   995
    __final_insertion_sort(__first, __last, __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   996
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   997
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   998
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
   999
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1000
void sort(_RandomAccessIter __first, _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1001
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1002
  if (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1003
    __introsort_loop(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1004
                     _STLP_VALUE_TYPE(__first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1005
                     __lg(__last - __first) * 2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1006
                     __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1007
    __final_insertion_sort(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1008
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1009
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1010
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1011
// stable_sort() and its auxiliary functions.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1012
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1013
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1014
void __inplace_stable_sort(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1015
                           _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1016
  if (__last - __first < 15) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1017
    __insertion_sort(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1018
    return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1019
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1020
  _RandomAccessIter __middle = __first + (__last - __first) / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1021
  __inplace_stable_sort(__first, __middle, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1022
  __inplace_stable_sort(__middle, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1023
  __merge_without_buffer(__first, __middle, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1024
                         __middle - __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1025
                         __last - __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1026
                         __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1027
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1028
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1029
template <class _RandomAccessIter1, class _RandomAccessIter2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1030
          class _Distance, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1031
void __merge_sort_loop(_RandomAccessIter1 __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1032
                       _RandomAccessIter1 __last, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1033
                       _RandomAccessIter2 __result, _Distance __step_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1034
                       _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1035
  _Distance __two_step = 2 * __step_size;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1036
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1037
  while (__last - __first >= __two_step) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1038
    __result = merge(__first, __first + __step_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1039
                     __first + __step_size, __first + __two_step,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1040
                     __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1041
                     __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1042
    __first += __two_step;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1043
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1044
  __step_size = (min) (_Distance(__last - __first), __step_size);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1045
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1046
  merge(__first, __first + __step_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1047
        __first + __step_size, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1048
        __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1049
        __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1050
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1051
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1052
const int __stl_chunk_size = 7;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1053
        
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1054
template <class _RandomAccessIter, class _Distance, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1055
void __chunk_insertion_sort(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1056
                            _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1057
                            _Distance __chunk_size, _Compare __comp)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1058
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1059
  while (__last - __first >= __chunk_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1060
    __insertion_sort(__first, __first + __chunk_size, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1061
    __first += __chunk_size;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1062
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1063
  __insertion_sort(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1064
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1065
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1066
template <class _RandomAccessIter, class _Pointer, class _Distance,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1067
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1068
void __merge_sort_with_buffer(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1069
                              _RandomAccessIter __last, _Pointer __buffer,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1070
                              _Distance*, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1071
  _Distance __len = __last - __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1072
  _Pointer __buffer_last = __buffer + __len;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1073
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1074
  _Distance __step_size = __stl_chunk_size;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1075
  __chunk_insertion_sort(__first, __last, __step_size, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1076
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1077
  while (__step_size < __len) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1078
    __merge_sort_loop(__first, __last, __buffer, __step_size, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1079
    __step_size *= 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1080
    __merge_sort_loop(__buffer, __buffer_last, __first, __step_size, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1081
    __step_size *= 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1082
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1083
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1084
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1085
template <class _BidirectionalIter1, class _BidirectionalIter2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1086
          class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1087
_BidirectionalIter1 __rotate_adaptive(_BidirectionalIter1 __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1088
                                      _BidirectionalIter1 __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1089
                                      _BidirectionalIter1 __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1090
                                      _Distance __len1, _Distance __len2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1091
                                      _BidirectionalIter2 __buffer,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1092
                                      _Distance __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1093
  if (__len1 > __len2 && __len2 <= __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1094
    _BidirectionalIter2 __buffer_end = copy(__middle, __last, __buffer);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1095
    copy_backward(__first, __middle, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1096
    return copy(__buffer, __buffer_end, __first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1097
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1098
  else if (__len1 <= __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1099
    _BidirectionalIter2 __buffer_end = copy(__first, __middle, __buffer);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1100
    copy(__middle, __last, __first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1101
    return copy_backward(__buffer, __buffer_end, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1102
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1103
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1104
    return rotate(__first, __middle, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1105
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1106
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1107
template <class _BidirectionalIter, class _Distance, class _Pointer,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1108
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1109
void __merge_adaptive(_BidirectionalIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1110
                      _BidirectionalIter __middle, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1111
                      _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1112
                      _Distance __len1, _Distance __len2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1113
                      _Pointer __buffer, _Distance __buffer_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1114
                      _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1115
  if (__len1 <= __len2 && __len1 <= __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1116
    _Pointer __buffer_end = copy(__first, __middle, __buffer);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1117
    merge(__buffer, __buffer_end, __middle, __last, __first, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1118
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1119
  else if (__len2 <= __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1120
    _Pointer __buffer_end = copy(__middle, __last, __buffer);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1121
    __merge_backward(__first, __middle, __buffer, __buffer_end, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1122
                     __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1123
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1124
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1125
    _BidirectionalIter __first_cut = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1126
    _BidirectionalIter __second_cut = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1127
    _Distance __len11 = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1128
    _Distance __len22 = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1129
    if (__len1 > __len2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1130
      __len11 = __len1 / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1131
      advance(__first_cut, __len11);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1132
      __second_cut = lower_bound(__middle, __last, *__first_cut, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1133
      __len22 += distance(__middle, __second_cut);   
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1134
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1135
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1136
      __len22 = __len2 / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1137
      advance(__second_cut, __len22);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1138
      __first_cut = upper_bound(__first, __middle, *__second_cut, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1139
      __len11 += distance(__first, __first_cut);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1140
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1141
    _BidirectionalIter __new_middle =
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1142
      __rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1143
                        __len22, __buffer, __buffer_size);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1144
    __merge_adaptive(__first, __first_cut, __new_middle, __len11,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1145
                     __len22, __buffer, __buffer_size, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1146
    __merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1147
                     __len2 - __len22, __buffer, __buffer_size, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1148
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1149
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1150
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1151
template <class _RandomAccessIter, class _Pointer, class _Distance, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1152
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1153
void __stable_sort_adaptive(_RandomAccessIter __first, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1154
                            _RandomAccessIter __last, _Pointer __buffer,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1155
                            _Distance __buffer_size, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1156
  _Distance __len = (__last - __first + 1) / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1157
  _RandomAccessIter __middle = __first + __len;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1158
  if (__len > __buffer_size) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1159
    __stable_sort_adaptive(__first, __middle, __buffer, __buffer_size, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1160
                           __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1161
    __stable_sort_adaptive(__middle, __last, __buffer, __buffer_size, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1162
                           __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1163
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1164
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1165
    __merge_sort_with_buffer(__first, __middle, __buffer, (_Distance*)0,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1166
                               __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1167
    __merge_sort_with_buffer(__middle, __last, __buffer, (_Distance*)0,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1168
                               __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1169
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1170
  __merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1171
                   _Distance(__last - __middle), __buffer, __buffer_size,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1172
                   __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1173
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1174
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1175
template <class _RandomAccessIter, class _Tp, class _Distance, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1176
void __stable_sort_aux(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1177
			      _RandomAccessIter __last, _Tp*, _Distance*,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1178
			      _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1179
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1180
  typedef _Temporary_buffer<_RandomAccessIter, _Tp> _TmpBuf;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1181
  _TmpBuf __buf(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1182
  _STLP_PUSH_STACK_ITEM(_TmpBuf, &__buf);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1183
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1184
  if (__buf.begin() == 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1185
    __inplace_stable_sort(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1186
  else 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1187
    __stable_sort_adaptive(__first, __last, __buf.begin(),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1188
                           _Distance(__buf.size()),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1189
                           __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1190
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1191
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1192
template <class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1193
void stable_sort(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1194
		 _RandomAccessIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1195
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1196
  __stable_sort_aux(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1197
                    _STLP_VALUE_TYPE(__first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1198
                    _STLP_DISTANCE_TYPE(__first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1199
                    __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1200
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1201
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1202
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1203
void stable_sort(_RandomAccessIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1204
		 _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1205
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1206
  __stable_sort_aux(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1207
                    _STLP_VALUE_TYPE(__first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1208
                    _STLP_DISTANCE_TYPE(__first, _RandomAccessIter), 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1209
                    __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1210
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1211
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1212
// partial_sort, partial_sort_copy, and auxiliary functions.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1213
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1214
template <class _RandomAccessIter, class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1215
void __partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1216
                    _RandomAccessIter __last, _Tp*, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1217
  make_heap(__first, __middle, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1218
  for (_RandomAccessIter __i = __middle; __i < __last; ++__i)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1219
    if (__comp(*__i, *__first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1220
      __pop_heap(__first, __middle, __i, _Tp(*__i), __comp,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1221
                 _STLP_DISTANCE_TYPE(__first, _RandomAccessIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1222
  sort_heap(__first, __middle, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1223
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1224
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1225
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1226
template <class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1227
void 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1228
partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, _RandomAccessIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1229
  _STLP_DEBUG_CHECK(__check_range(__first, __middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1230
  _STLP_DEBUG_CHECK(__check_range(__middle, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1231
  __partial_sort(__first, __middle, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1232
                 __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1233
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1234
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1235
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1236
void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1237
                  _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1238
  _STLP_DEBUG_CHECK(__check_range(__first, __middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1239
  _STLP_DEBUG_CHECK(__check_range(__middle, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1240
  __partial_sort(__first, __middle, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1241
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1242
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1243
template <class _InputIter, class _RandomAccessIter, class _Compare,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1244
          class _Distance, class _Tp>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1245
_RandomAccessIter __partial_sort_copy(_InputIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1246
                                         _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1247
                                         _RandomAccessIter __result_first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1248
                                         _RandomAccessIter __result_last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1249
                                         _Compare __comp, _Distance*, _Tp*) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1250
  if (__result_first == __result_last) return __result_last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1251
  _RandomAccessIter __result_real_last = __result_first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1252
  while(__first != __last && __result_real_last != __result_last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1253
    *__result_real_last = *__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1254
    ++__result_real_last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1255
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1256
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1257
  make_heap(__result_first, __result_real_last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1258
  while (__first != __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1259
    if (__comp(*__first, *__result_first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1260
      __adjust_heap(__result_first, _Distance(0),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1261
                    _Distance(__result_real_last - __result_first),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1262
                    _Tp(*__first),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1263
                    __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1264
    ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1265
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1266
  sort_heap(__result_first, __result_real_last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1267
  return __result_real_last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1268
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1269
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1270
template <class _InputIter, class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1271
_RandomAccessIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1272
partial_sort_copy(_InputIter __first, _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1273
                  _RandomAccessIter __result_first, _RandomAccessIter __result_last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1274
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1275
  _STLP_DEBUG_CHECK(__check_range(__result_first, __result_last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1276
  return __partial_sort_copy(__first, __last, __result_first, __result_last, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1277
                             __less(_STLP_VALUE_TYPE(__first, _InputIter)),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1278
                             _STLP_DISTANCE_TYPE(__result_first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1279
                             _STLP_VALUE_TYPE(__first, _InputIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1280
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1281
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1282
template <class _InputIter, class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1283
_RandomAccessIter
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1284
partial_sort_copy(_InputIter __first, _InputIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1285
                  _RandomAccessIter __result_first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1286
                  _RandomAccessIter __result_last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1287
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1288
  _STLP_DEBUG_CHECK(__check_range(__result_first, __result_last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1289
  return __partial_sort_copy(__first, __last, __result_first, __result_last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1290
                             __comp,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1291
                             _STLP_DISTANCE_TYPE(__result_first, _RandomAccessIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1292
                             _STLP_VALUE_TYPE(__first, _InputIter));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1293
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1294
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1295
// nth_element() and its auxiliary functions.  
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1296
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1297
template <class _RandomAccessIter, class _Tp, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1298
void __nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1299
                   _RandomAccessIter __last, _Tp*, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1300
  while (__last - __first > 3) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1301
    _RandomAccessIter __cut =
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1302
      __unguarded_partition(__first, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1303
                            _Tp(__median(*__first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1304
                                         *(__first + (__last - __first)/2), 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1305
                                         *(__last - 1),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1306
                                         __comp)),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1307
                            __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1308
    if (__cut <= __nth)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1309
      __first = __cut;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1310
    else 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1311
      __last = __cut;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1312
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1313
  __insertion_sort(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1314
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1315
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1316
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1317
template <class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1318
void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1319
                 _RandomAccessIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1320
  _STLP_DEBUG_CHECK(__check_range(__first, __nth))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1321
  _STLP_DEBUG_CHECK(__check_range(__nth, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1322
  __nth_element(__first, __nth, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1323
                __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1324
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1325
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1326
template <class _RandomAccessIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1327
void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1328
                 _RandomAccessIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1329
  _STLP_DEBUG_CHECK(__check_range(__first, __nth))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1330
  _STLP_DEBUG_CHECK(__check_range(__nth, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1331
  __nth_element(__first, __nth, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIter), __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1332
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1333
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1334
// Binary search (lower_bound, upper_bound, equal_range, binary_search).
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1335
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1336
template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1337
_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1338
                           const _Tp& __val, _Compare __comp, _Distance*)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1339
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1340
  _Distance __len = distance(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1341
  _Distance __half;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1342
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1343
  while (__len > 0) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1344
    __half = __len >> 1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1345
    _ForwardIter __middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1346
    advance(__middle, __half);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1347
    if (__comp(__val, *__middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1348
      __len = __half;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1349
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1350
      __first = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1351
      ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1352
      __len = __len - __half - 1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1353
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1354
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1355
  return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1356
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1357
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1358
template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1359
pair<_ForwardIter, _ForwardIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1360
__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1361
              _Compare __comp, _Distance*)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1362
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1363
  _Distance __len = distance(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1364
  _Distance __half;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1365
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1366
  while (__len > 0) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1367
    __half = __len >> 1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1368
    _ForwardIter __middle = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1369
    advance(__middle, __half);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1370
    if (__comp(*__middle, __val)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1371
      __first = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1372
      ++__first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1373
      __len = __len - __half - 1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1374
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1375
    else if (__comp(__val, *__middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1376
      __len = __half;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1377
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1378
      _ForwardIter __left = lower_bound(__first, __middle, __val, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1379
      advance(__first, __len);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1380
      _ForwardIter __right = upper_bound(++__middle, __first, __val, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1381
      return pair<_ForwardIter, _ForwardIter>(__left, __right);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1382
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1383
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1384
  return pair<_ForwardIter, _ForwardIter>(__first, __first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1385
}           
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1386
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1387
template <class _InputIter1, class _InputIter2, class _OutputIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1388
_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1389
                  _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1390
                  _OutputIter __result) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1391
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1392
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1393
  while (__first1 != __last1 && __first2 != __last2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1394
    if (*__first2 < *__first1) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1395
      *__result = *__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1396
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1397
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1398
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1399
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1400
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1401
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1402
    ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1403
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1404
  return copy(__first2, __last2, copy(__first1, __last1, __result));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1405
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1406
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1407
template <class _InputIter1, class _InputIter2, class _OutputIter,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1408
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1409
_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1410
                  _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1411
                  _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1412
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1413
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1414
  while (__first1 != __last1 && __first2 != __last2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1415
    if (__comp(*__first2, *__first1)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1416
      *__result = *__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1417
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1418
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1419
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1420
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1421
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1422
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1423
    ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1424
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1425
  return copy(__first2, __last2, copy(__first1, __last1, __result));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1426
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1427
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1428
template <class _BidirectionalIter, class _Distance, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1429
void __merge_without_buffer(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1430
                            _BidirectionalIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1431
                            _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1432
                            _Distance __len1, _Distance __len2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1433
                            _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1434
  if (__len1 == 0 || __len2 == 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1435
    return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1436
  if (__len1 + __len2 == 2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1437
    if (__comp(*__middle, *__first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1438
      iter_swap(__first, __middle);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1439
    return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1440
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1441
  _BidirectionalIter __first_cut = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1442
  _BidirectionalIter __second_cut = __middle;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1443
  _Distance __len11 = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1444
  _Distance __len22 = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1445
  if (__len1 > __len2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1446
    __len11 = __len1 / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1447
    advance(__first_cut, __len11);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1448
    __second_cut = lower_bound(__middle, __last, *__first_cut, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1449
    __len22 += distance(__middle, __second_cut);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1450
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1451
  else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1452
    __len22 = __len2 / 2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1453
    advance(__second_cut, __len22);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1454
    __first_cut = upper_bound(__first, __middle, *__second_cut, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1455
    __len11 +=distance(__first, __first_cut);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1456
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1457
  _BidirectionalIter __new_middle
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1458
    = rotate(__first_cut, __middle, __second_cut);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1459
  __merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1460
                         __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1461
  __merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1462
                         __len2 - __len22, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1463
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1464
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1465
template <class _BidirectionalIter1, class _BidirectionalIter2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1466
          class _BidirectionalIter3, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1467
_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1468
                                     _BidirectionalIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1469
                                     _BidirectionalIter2 __first2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1470
                                     _BidirectionalIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1471
                                     _BidirectionalIter3 __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1472
                                     _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1473
  if (__first1 == __last1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1474
    return copy_backward(__first2, __last2, __result);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1475
  if (__first2 == __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1476
    return copy_backward(__first1, __last1, __result);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1477
  --__last1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1478
  --__last2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1479
  while (true) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1480
    if (__comp(*__last2, *__last1)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1481
      *--__result = *__last1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1482
      if (__first1 == __last1)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1483
        return copy_backward(__first2, ++__last2, __result);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1484
      --__last1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1485
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1486
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1487
      *--__result = *__last2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1488
      if (__first2 == __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1489
        return copy_backward(__first1, ++__last1, __result);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1490
      --__last2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1491
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1492
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1493
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1494
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1495
template <class _BidirectionalIter, class _Tp, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1496
          class _Distance, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1497
inline void __inplace_merge_aux(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1498
                                _BidirectionalIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1499
                                _BidirectionalIter __last, _Tp*, _Distance*,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1500
                                _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1501
  _Distance __len1 = distance(__first, __middle);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1502
  _Distance __len2 = distance(__middle, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1503
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1504
  typedef _Temporary_buffer<_BidirectionalIter, _Tp> _TmpBuf;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1505
  _TmpBuf __buf(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1506
  _STLP_PUSH_STACK_ITEM(_TmpBuf, &__buf);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1507
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1508
  if (__buf.begin() == 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1509
    __merge_without_buffer(__first, __middle, __last, __len1, __len2, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1510
  else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1511
    __merge_adaptive(__first, __middle, __last, __len1, __len2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1512
                     __buf.begin(), _Distance(__buf.size()),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1513
                     __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1514
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1515
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1516
template <class _BidirectionalIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1517
void inplace_merge(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1518
		   _BidirectionalIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1519
		   _BidirectionalIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1520
  _STLP_DEBUG_CHECK(__check_range(__first, __middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1521
  _STLP_DEBUG_CHECK(__check_range(__middle, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1522
  if (__first == __middle || __middle == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1523
    return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1524
  __inplace_merge_aux(__first, __middle, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1525
                      _STLP_VALUE_TYPE(__first, _BidirectionalIter), _STLP_DISTANCE_TYPE(__first, _BidirectionalIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1526
                      __less(_STLP_VALUE_TYPE(__first, _BidirectionalIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1527
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1528
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1529
template <class _BidirectionalIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1530
void inplace_merge(_BidirectionalIter __first,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1531
		   _BidirectionalIter __middle,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1532
		   _BidirectionalIter __last, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1533
  _STLP_DEBUG_CHECK(__check_range(__first, __middle))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1534
  _STLP_DEBUG_CHECK(__check_range(__middle, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1535
  if (__first == __middle || __middle == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1536
    return;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1537
  __inplace_merge_aux(__first, __middle, __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1538
                      _STLP_VALUE_TYPE(__first, _BidirectionalIter), _STLP_DISTANCE_TYPE(__first, _BidirectionalIter),
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1539
                      __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1540
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1541
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1542
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1543
template <class _InputIter1, class _InputIter2, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1544
bool __includes(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1545
                _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1546
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1547
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1548
  while (__first1 != __last1 && __first2 != __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1549
    if (__comp(*__first2, *__first1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1550
      return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1551
    else if(__comp(*__first1, *__first2)) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1552
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1553
    else
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1554
      ++__first1, ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1555
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1556
  return __first2 == __last2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1557
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1558
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1559
template <class _InputIter1, class _InputIter2, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1560
bool includes(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1561
              _InputIter2 __first2, _InputIter2 __last2, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1562
  return __includes(__first1, __last1, __first2, __last2, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1563
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1564
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1565
template <class _InputIter1, class _InputIter2>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1566
bool includes(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1567
              _InputIter2 __first2, _InputIter2 __last2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1568
  return __includes(__first1, __last1, __first2, __last2, __less(_STLP_VALUE_TYPE(__first1, _InputIter1)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1569
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1570
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1571
template <class _InputIter1, class _InputIter2, class _OutputIter,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1572
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1573
_OutputIter __set_union(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1574
                        _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1575
                        _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1576
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1577
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1578
  while (__first1 != __last1 && __first2 != __last2) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1579
    if (__comp(*__first1, *__first2)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1580
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1581
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1582
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1583
    else if (__comp(*__first2, *__first1)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1584
      *__result = *__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1585
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1586
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1587
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1588
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1589
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1590
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1591
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1592
    ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1593
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1594
  return copy(__first2, __last2, copy(__first1, __last1, __result));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1595
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1596
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1597
template <class _InputIter1, class _InputIter2, class _OutputIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1598
_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1599
                      _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1600
                      _OutputIter __result) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1601
  return __set_union(__first1, __last1, __first2, __last2, __result, __less(_STLP_VALUE_TYPE(__first1, _InputIter1)));  
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1602
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1603
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1604
template <class _InputIter1, class _InputIter2, class _OutputIter,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1605
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1606
_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1607
                      _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1608
                      _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1609
  return __set_union(__first1, __last1, __first2, __last2, __result, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1610
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1611
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1612
template <class _InputIter1, class _InputIter2, class _OutputIter,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1613
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1614
_OutputIter __set_intersection(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1615
                               _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1616
                               _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1617
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1618
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1619
  while (__first1 != __last1 && __first2 != __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1620
    if (__comp(*__first1, *__first2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1621
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1622
    else if (__comp(*__first2, *__first1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1623
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1624
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1625
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1626
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1627
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1628
      ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1629
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1630
  return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1631
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1632
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1633
template <class _InputIter1, class _InputIter2, class _OutputIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1634
_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1635
                             _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1636
                             _OutputIter __result) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1637
  return __set_intersection(__first1, __last1, __first2, __last2, __result, __less(_STLP_VALUE_TYPE(__first1, _InputIter1)));  
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1638
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1639
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1640
template <class _InputIter1, class _InputIter2, class _OutputIter,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1641
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1642
_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1643
                             _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1644
                             _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1645
  return __set_intersection(__first1, __last1, __first2, __last2, __result, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1646
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1647
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1648
template <class _InputIter1, class _InputIter2, class _OutputIter, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1649
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1650
_OutputIter __set_difference(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1651
                             _InputIter2 __first2, _InputIter2 __last2, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1652
                             _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1653
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1654
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1655
  while (__first1 != __last1 && __first2 != __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1656
    if (__comp(*__first1, *__first2)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1657
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1658
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1659
      ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1660
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1661
    else if (__comp(*__first2, *__first1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1662
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1663
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1664
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1665
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1666
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1667
  return copy(__first1, __last1, __result);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1668
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1669
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1670
template <class _InputIter1, class _InputIter2, class _OutputIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1671
_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1672
                           _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1673
                           _OutputIter __result) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1674
  return __set_difference(__first1, __last1, __first2, __last2, __result, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1675
                          __less(_STLP_VALUE_TYPE(__first1, _InputIter1)));  
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1676
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1677
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1678
template <class _InputIter1, class _InputIter2, class _OutputIter, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1679
          class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1680
_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1681
                           _InputIter2 __first2, _InputIter2 __last2, 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1682
                           _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1683
  return __set_difference(__first1, __last1, __first2, __last2, __result, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1684
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1685
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1686
template <class _InputIter1, class _InputIter2, class _OutputIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1687
_OutputIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1688
__set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1689
                           _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1690
                           _OutputIter __result, _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1691
  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1692
  _STLP_DEBUG_CHECK(__check_range(__first2, __last2))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1693
  while (__first1 != __last1 && __first2 != __last2)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1694
    if (__comp(*__first1, *__first2)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1695
      *__result = *__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1696
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1697
      ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1698
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1699
    else if (__comp(*__first2, *__first1)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1700
      *__result = *__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1701
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1702
      ++__result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1703
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1704
    else {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1705
      ++__first1;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1706
      ++__first2;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1707
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1708
  return copy(__first2, __last2, copy(__first1, __last1, __result));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1709
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1710
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1711
template <class _InputIter1, class _InputIter2, class _OutputIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1712
_OutputIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1713
set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1714
                         _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1715
                         _OutputIter __result) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1716
  return __set_symmetric_difference(__first1, __last1, __first2, __last2, __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1717
                                    __less(_STLP_VALUE_TYPE(__first1, _InputIter1)));  
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1718
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1719
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1720
template <class _InputIter1, class _InputIter2, class _OutputIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1721
_OutputIter 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1722
set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1723
                         _InputIter2 __first2, _InputIter2 __last2,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1724
                         _OutputIter __result,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1725
                         _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1726
  return __set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1727
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1728
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1729
// min_element and max_element, with and without an explicitly supplied
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1730
// comparison function.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1731
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1732
template <class _ForwardIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1733
_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1734
                            _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1735
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1736
  if (__first == __last) return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1737
  _ForwardIter __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1738
  while (++__first != __last) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1739
    if (__comp(*__result, *__first)) __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1740
  return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1741
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1742
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1743
template <class _ForwardIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1744
_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1745
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1746
  if (__first == __last) return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1747
  _ForwardIter __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1748
  while (++__first != __last) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1749
    if (*__result < *__first)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1750
      __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1751
  return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1752
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1753
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1754
template <class _ForwardIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1755
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1756
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1757
  if (__first == __last) return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1758
  _ForwardIter __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1759
  while (++__first != __last) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1760
    if (*__first < *__result)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1761
      __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1762
  return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1763
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1764
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1765
template <class _ForwardIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1766
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1767
                            _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1768
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1769
  if (__first == __last) return __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1770
  _ForwardIter __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1771
  while (++__first != __last) 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1772
    if (__comp(*__first, *__result)) __result = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1773
  return __result;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1774
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1775
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1776
// next_permutation and prev_permutation, with and without an explicitly 
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1777
// supplied comparison function.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1778
template <class _BidirectionalIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1779
bool __next_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1780
                        _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1781
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1782
  if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1783
    return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1784
  _BidirectionalIter __i = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1785
  ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1786
  if (__i == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1787
    return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1788
  __i = __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1789
  --__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1790
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1791
  for(;;) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1792
    _BidirectionalIter __ii = __i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1793
    --__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1794
    if (__comp(*__i, *__ii)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1795
      _BidirectionalIter __j = __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1796
      while (!__comp(*__i, *--__j))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1797
        {}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1798
      iter_swap(__i, __j);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1799
      reverse(__ii, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1800
      return true;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1801
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1802
    if (__i == __first) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1803
      reverse(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1804
      return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1805
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1806
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1807
#if defined(_STLP_NEED_UNREACHABLE_RETURN)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1808
    return 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1809
#endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1810
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1811
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1812
template <class _BidirectionalIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1813
bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1814
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1815
  return __next_permutation(__first, __last, __less(_STLP_VALUE_TYPE(__first, _BidirectionalIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1816
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1817
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1818
template <class _BidirectionalIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1819
bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1820
                      _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1821
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1822
  return __next_permutation(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1823
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1824
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1825
template <class _BidirectionalIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1826
bool __prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1827
                      _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1828
  if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1829
    return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1830
  _BidirectionalIter __i = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1831
  ++__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1832
  if (__i == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1833
    return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1834
  __i = __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1835
  --__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1836
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1837
  for(;;) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1838
    _BidirectionalIter __ii = __i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1839
    --__i;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1840
    if (__comp(*__ii, *__i)) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1841
      _BidirectionalIter __j = __last;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1842
      while (!__comp(*--__j, *__i))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1843
        {}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1844
      iter_swap(__i, __j);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1845
      reverse(__ii, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1846
      return true;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1847
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1848
    if (__i == __first) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1849
      reverse(__first, __last);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1850
      return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1851
    }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1852
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1853
#if defined(_STLP_NEED_UNREACHABLE_RETURN)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1854
    return 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1855
#endif
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1856
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1857
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1858
template <class _BidirectionalIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1859
bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1860
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1861
  return __prev_permutation(__first, __last, __less(_STLP_VALUE_TYPE(__first, _BidirectionalIter)));
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1862
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1863
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1864
template <class _BidirectionalIter, class _Compare>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1865
bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1866
                      _Compare __comp) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1867
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1868
  return __prev_permutation(__first, __last, __comp);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1869
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1870
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1871
# ifndef _STLP_NO_EXTENSIONS
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1872
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1873
// is_heap, a predicate testing whether or not a range is
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1874
// a heap.  This function is an extension, not part of the C++
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1875
// standard.
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1876
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1877
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1878
template <class _RandomAccessIter, class _Distance, class _StrictWeakOrdering>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1879
bool __is_heap(_RandomAccessIter __first, _StrictWeakOrdering __comp,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1880
               _Distance __n)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1881
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1882
  _Distance __parent = 0;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1883
  for (_Distance __child = 1; __child < __n; ++__child) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1884
    if (__comp(__first[__parent], __first[__child]))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1885
      return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1886
    if ((__child & 1) == 0)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1887
      ++__parent;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1888
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1889
  return true;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1890
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1891
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1892
template <class _RandomAccessIter>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1893
bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1894
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1895
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1896
  return __is_heap(__first, __less(_STLP_VALUE_TYPE(__first, _RandomAccessIter)), __last - __first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1897
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1898
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1899
template <class _RandomAccessIter, class _StrictWeakOrdering>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1900
bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1901
	     _StrictWeakOrdering __comp)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1902
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1903
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1904
  return __is_heap(__first, __comp, __last - __first);
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1905
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1906
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1907
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1908
template <class _ForwardIter, class _StrictWeakOrdering>
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1909
bool __is_sorted(_ForwardIter __first, _ForwardIter __last,
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1910
                 _StrictWeakOrdering __comp)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1911
{
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1912
  _STLP_DEBUG_CHECK(__check_range(__first, __last))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1913
  if (__first == __last)
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1914
    return true;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1915
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1916
  _ForwardIter __next = __first;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1917
  for (++__next; __next != __last; __first = __next, ++__next) {
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1918
    if (__comp(*__next, *__first))
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1919
      return false;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1920
  }
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1921
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1922
  return true;
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1923
}
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1924
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1925
# endif /* _STLP_NO_EXTENSIONS */
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1926
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1927
_STLP_END_NAMESPACE
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1928
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1929
# undef __stl_threshold
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1930
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1931
#endif /* _STLP_ALGO_C */
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1932
// Local Variables:
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1933
// mode:C++
837f303aceeb Current Symbian^3 public API header files (from PDK 3.0.h)
William Roberts <williamr@symbian.org>
parents:
diff changeset
  1934
// End: