williamr@4
|
1 |
/*
|
williamr@4
|
2 |
*
|
williamr@4
|
3 |
* Copyright (c) 1994
|
williamr@4
|
4 |
* Hewlett-Packard Company
|
williamr@4
|
5 |
*
|
williamr@4
|
6 |
* Copyright (c) 1996,1997
|
williamr@4
|
7 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@4
|
8 |
*
|
williamr@4
|
9 |
* Copyright (c) 1997
|
williamr@4
|
10 |
* Moscow Center for SPARC Technology
|
williamr@4
|
11 |
*
|
williamr@4
|
12 |
* Copyright (c) 1999
|
williamr@4
|
13 |
* Boris Fomitchev
|
williamr@4
|
14 |
*
|
williamr@4
|
15 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@4
|
16 |
* or implied. Any use is at your own risk.
|
williamr@4
|
17 |
*
|
williamr@4
|
18 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@4
|
19 |
* without fee, provided the above notices are retained on all copies.
|
williamr@4
|
20 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@4
|
21 |
* provided the above notices are retained, and a notice that the code was
|
williamr@4
|
22 |
* modified is included with the above copyright notice.
|
williamr@4
|
23 |
*
|
williamr@4
|
24 |
*/
|
williamr@4
|
25 |
|
williamr@4
|
26 |
/* NOTE: This is an internal header file, included by other STL headers.
|
williamr@4
|
27 |
* You should not attempt to use it directly.
|
williamr@4
|
28 |
*/
|
williamr@4
|
29 |
|
williamr@4
|
30 |
#ifndef _STLP_INTERNAL_ALGO_H
|
williamr@4
|
31 |
#define _STLP_INTERNAL_ALGO_H
|
williamr@4
|
32 |
|
williamr@4
|
33 |
# ifndef _STLP_INTERNAL_ALGOBASE_H
|
williamr@4
|
34 |
# include <stl/_algobase.h>
|
williamr@4
|
35 |
# endif
|
williamr@4
|
36 |
|
williamr@4
|
37 |
# ifndef _STLP_INTERNAL_TEMPBUF_H
|
williamr@4
|
38 |
# include <stl/_tempbuf.h>
|
williamr@4
|
39 |
# endif
|
williamr@4
|
40 |
|
williamr@4
|
41 |
# ifndef _STLP_INTERNAL_HEAP_H
|
williamr@4
|
42 |
# include <stl/_heap.h>
|
williamr@4
|
43 |
# endif
|
williamr@4
|
44 |
|
williamr@4
|
45 |
# ifndef _STLP_INTERNAL_ITERATOR_H
|
williamr@4
|
46 |
# include <stl/_iterator.h>
|
williamr@4
|
47 |
# endif
|
williamr@4
|
48 |
|
williamr@4
|
49 |
# ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
williamr@4
|
50 |
# include <stl/_function_base.h>
|
williamr@4
|
51 |
# endif
|
williamr@4
|
52 |
|
williamr@4
|
53 |
# ifdef __SUNPRO_CC
|
williamr@4
|
54 |
// remove() conflict
|
williamr@4
|
55 |
# include <cstdio>
|
williamr@4
|
56 |
# endif
|
williamr@4
|
57 |
|
williamr@4
|
58 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
59 |
|
williamr@4
|
60 |
// for_each. Apply a function to every element of a range.
|
williamr@4
|
61 |
template <class _InputIter, class _Function>
|
williamr@4
|
62 |
_STLP_INLINE_LOOP _Function
|
williamr@4
|
63 |
for_each(_InputIter __first, _InputIter __last, _Function __f) {
|
williamr@4
|
64 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
65 |
__f(*__first);
|
williamr@4
|
66 |
return __f;
|
williamr@4
|
67 |
}
|
williamr@4
|
68 |
|
williamr@4
|
69 |
// count_if
|
williamr@4
|
70 |
template <class _InputIter, class _Predicate>
|
williamr@4
|
71 |
_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
|
williamr@4
|
72 |
count_if(_InputIter __first, _InputIter __last, _Predicate __pred) {
|
williamr@4
|
73 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
74 |
_STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
|
williamr@4
|
75 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
76 |
if (__pred(*__first))
|
williamr@4
|
77 |
++__n;
|
williamr@4
|
78 |
return __n;
|
williamr@4
|
79 |
}
|
williamr@4
|
80 |
|
williamr@4
|
81 |
// adjacent_find.
|
williamr@4
|
82 |
|
williamr@4
|
83 |
template <class _ForwardIter, class _BinaryPredicate>
|
williamr@4
|
84 |
_STLP_INLINE_LOOP _ForwardIter
|
williamr@4
|
85 |
adjacent_find(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
86 |
_BinaryPredicate __binary_pred) {
|
williamr@4
|
87 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
88 |
if (__first == __last)
|
williamr@4
|
89 |
return __last;
|
williamr@4
|
90 |
_ForwardIter __next = __first;
|
williamr@4
|
91 |
while(++__next != __last) {
|
williamr@4
|
92 |
if (__binary_pred(*__first, *__next))
|
williamr@4
|
93 |
return __first;
|
williamr@4
|
94 |
__first = __next;
|
williamr@4
|
95 |
}
|
williamr@4
|
96 |
return __last;
|
williamr@4
|
97 |
}
|
williamr@4
|
98 |
|
williamr@4
|
99 |
template <class _ForwardIter>
|
williamr@4
|
100 |
_STLP_INLINE_LOOP _ForwardIter
|
williamr@4
|
101 |
adjacent_find(_ForwardIter __first, _ForwardIter __last) {
|
williamr@4
|
102 |
return adjacent_find(__first, __last,
|
williamr@4
|
103 |
__equal_to(_STLP_VALUE_TYPE(__first, _ForwardIter)));
|
williamr@4
|
104 |
}
|
williamr@4
|
105 |
|
williamr@4
|
106 |
# ifndef _STLP_NO_ANACHRONISMS
|
williamr@4
|
107 |
template <class _InputIter, class _Tp, class _Size>
|
williamr@4
|
108 |
_STLP_INLINE_LOOP void
|
williamr@4
|
109 |
count(_InputIter __first, _InputIter __last, const _Tp& __val, _Size& __n) {
|
williamr@4
|
110 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
111 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
112 |
if (*__first == __val)
|
williamr@4
|
113 |
++__n;
|
williamr@4
|
114 |
}
|
williamr@4
|
115 |
|
williamr@4
|
116 |
template <class _InputIter, class _Predicate, class _Size>
|
williamr@4
|
117 |
_STLP_INLINE_LOOP void
|
williamr@4
|
118 |
count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size& __n) {
|
williamr@4
|
119 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
120 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
121 |
if (__pred(*__first))
|
williamr@4
|
122 |
++__n;
|
williamr@4
|
123 |
}
|
williamr@4
|
124 |
# endif
|
williamr@4
|
125 |
|
williamr@4
|
126 |
template <class _ForwardIter1, class _ForwardIter2>
|
williamr@4
|
127 |
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
williamr@4
|
128 |
_ForwardIter2 __first2, _ForwardIter2 __last2);
|
williamr@4
|
129 |
|
williamr@4
|
130 |
// search_n. Search for __count consecutive copies of __val.
|
williamr@4
|
131 |
template <class _ForwardIter, class _Integer, class _Tp>
|
williamr@4
|
132 |
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
133 |
_Integer __count, const _Tp& __val);
|
williamr@4
|
134 |
template <class _ForwardIter, class _Integer, class _Tp, class _BinaryPred>
|
williamr@4
|
135 |
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
136 |
_Integer __count, const _Tp& __val, _BinaryPred __binary_pred);
|
williamr@4
|
137 |
|
williamr@4
|
138 |
template <class _InputIter, class _ForwardIter>
|
williamr@4
|
139 |
inline _InputIter find_first_of(_InputIter __first1, _InputIter __last1,
|
williamr@4
|
140 |
_ForwardIter __first2, _ForwardIter __last2) {
|
williamr@4
|
141 |
_STLP_DEBUG_CHECK(__check_range(__first1, __last1))
|
williamr@4
|
142 |
_STLP_DEBUG_CHECK(__check_range(__first2, __last2))
|
williamr@4
|
143 |
return __find_first_of(__first1, __last1, __first2, __last2,__equal_to(_STLP_VALUE_TYPE(__first1, _InputIter)));
|
williamr@4
|
144 |
}
|
williamr@4
|
145 |
|
williamr@4
|
146 |
template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
|
williamr@4
|
147 |
inline _InputIter
|
williamr@4
|
148 |
find_first_of(_InputIter __first1, _InputIter __last1,
|
williamr@4
|
149 |
_ForwardIter __first2, _ForwardIter __last2,_BinaryPredicate __comp) {
|
williamr@4
|
150 |
_STLP_DEBUG_CHECK(__check_range(__first1, __last1))
|
williamr@4
|
151 |
_STLP_DEBUG_CHECK(__check_range(__first2, __last2))
|
williamr@4
|
152 |
return __find_first_of(__first1, __last1, __first2, __last2,__comp);
|
williamr@4
|
153 |
}
|
williamr@4
|
154 |
|
williamr@4
|
155 |
template <class _ForwardIter1, class _ForwardIter2>
|
williamr@4
|
156 |
_ForwardIter1
|
williamr@4
|
157 |
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
williamr@4
|
158 |
_ForwardIter2 __first2, _ForwardIter2 __last2);
|
williamr@4
|
159 |
|
williamr@4
|
160 |
// swap_ranges
|
williamr@4
|
161 |
template <class _ForwardIter1, class _ForwardIter2>
|
williamr@4
|
162 |
_STLP_INLINE_LOOP _ForwardIter2
|
williamr@4
|
163 |
swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2) {
|
williamr@4
|
164 |
_STLP_DEBUG_CHECK(__check_range(__first1, __last1))
|
williamr@4
|
165 |
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
williamr@4
|
166 |
iter_swap(__first1, __first2);
|
williamr@4
|
167 |
return __first2;
|
williamr@4
|
168 |
}
|
williamr@4
|
169 |
|
williamr@4
|
170 |
// transform
|
williamr@4
|
171 |
template <class _InputIter, class _OutputIter, class _UnaryOperation>
|
williamr@4
|
172 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
173 |
transform(_InputIter __first, _InputIter __last, _OutputIter __result, _UnaryOperation __opr) {
|
williamr@4
|
174 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
175 |
for ( ; __first != __last; ++__first, ++__result)
|
williamr@4
|
176 |
*__result = __opr(*__first);
|
williamr@4
|
177 |
return __result;
|
williamr@4
|
178 |
}
|
williamr@4
|
179 |
template <class _InputIter1, class _InputIter2, class _OutputIter, class _BinaryOperation>
|
williamr@4
|
180 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
181 |
transform(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
182 |
_InputIter2 __first2, _OutputIter __result,_BinaryOperation __binary_op) {
|
williamr@4
|
183 |
_STLP_DEBUG_CHECK(__check_range(__first1, __last1))
|
williamr@4
|
184 |
for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result)
|
williamr@4
|
185 |
*__result = __binary_op(*__first1, *__first2);
|
williamr@4
|
186 |
return __result;
|
williamr@4
|
187 |
}
|
williamr@4
|
188 |
|
williamr@4
|
189 |
// replace_if, replace_copy, replace_copy_if
|
williamr@4
|
190 |
|
williamr@4
|
191 |
template <class _ForwardIter, class _Predicate, class _Tp>
|
williamr@4
|
192 |
_STLP_INLINE_LOOP void
|
williamr@4
|
193 |
replace_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred, const _Tp& __new_value) {
|
williamr@4
|
194 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
195 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
196 |
if (__pred(*__first))
|
williamr@4
|
197 |
*__first = __new_value;
|
williamr@4
|
198 |
}
|
williamr@4
|
199 |
|
williamr@4
|
200 |
template <class _InputIter, class _OutputIter, class _Tp>
|
williamr@4
|
201 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
202 |
replace_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
|
williamr@4
|
203 |
const _Tp& __old_value, const _Tp& __new_value) {
|
williamr@4
|
204 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
205 |
for ( ; __first != __last; ++__first, ++__result)
|
williamr@4
|
206 |
*__result = *__first == __old_value ? __new_value : *__first;
|
williamr@4
|
207 |
return __result;
|
williamr@4
|
208 |
}
|
williamr@4
|
209 |
|
williamr@4
|
210 |
template <class _Iterator, class _OutputIter, class _Predicate, class _Tp>
|
williamr@4
|
211 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
212 |
replace_copy_if(_Iterator __first, _Iterator __last,
|
williamr@4
|
213 |
_OutputIter __result,
|
williamr@4
|
214 |
_Predicate __pred, const _Tp& __new_value) {
|
williamr@4
|
215 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
216 |
for ( ; __first != __last; ++__first, ++__result)
|
williamr@4
|
217 |
*__result = __pred(*__first) ? __new_value : *__first;
|
williamr@4
|
218 |
return __result;
|
williamr@4
|
219 |
}
|
williamr@4
|
220 |
|
williamr@4
|
221 |
// generate and generate_n
|
williamr@4
|
222 |
|
williamr@4
|
223 |
template <class _ForwardIter, class _Generator>
|
williamr@4
|
224 |
_STLP_INLINE_LOOP void
|
williamr@4
|
225 |
generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) {
|
williamr@4
|
226 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
227 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
228 |
*__first = __gen();
|
williamr@4
|
229 |
}
|
williamr@4
|
230 |
|
williamr@4
|
231 |
template <class _OutputIter, class _Size, class _Generator>
|
williamr@4
|
232 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
233 |
generate_n(_OutputIter __first, _Size __n, _Generator __gen) {
|
williamr@4
|
234 |
for ( ; __n > 0; --__n, ++__first)
|
williamr@4
|
235 |
*__first = __gen();
|
williamr@4
|
236 |
return __first;
|
williamr@4
|
237 |
}
|
williamr@4
|
238 |
|
williamr@4
|
239 |
// remove, remove_if, remove_copy, remove_copy_if
|
williamr@4
|
240 |
|
williamr@4
|
241 |
template <class _InputIter, class _OutputIter, class _Tp>
|
williamr@4
|
242 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
243 |
remove_copy(_InputIter __first, _InputIter __last,_OutputIter __result, const _Tp& __val) {
|
williamr@4
|
244 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
245 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
246 |
if (!(*__first == __val)) {
|
williamr@4
|
247 |
*__result = *__first;
|
williamr@4
|
248 |
++__result;
|
williamr@4
|
249 |
}
|
williamr@4
|
250 |
return __result;
|
williamr@4
|
251 |
}
|
williamr@4
|
252 |
|
williamr@4
|
253 |
template <class _InputIter, class _OutputIter, class _Predicate>
|
williamr@4
|
254 |
_STLP_INLINE_LOOP _OutputIter
|
williamr@4
|
255 |
remove_copy_if(_InputIter __first, _InputIter __last, _OutputIter __result, _Predicate __pred) {
|
williamr@4
|
256 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
257 |
for ( ; __first != __last; ++__first)
|
williamr@4
|
258 |
if (!__pred(*__first)) {
|
williamr@4
|
259 |
*__result = *__first;
|
williamr@4
|
260 |
++__result;
|
williamr@4
|
261 |
}
|
williamr@4
|
262 |
return __result;
|
williamr@4
|
263 |
}
|
williamr@4
|
264 |
|
williamr@4
|
265 |
template <class _ForwardIter, class _Tp>
|
williamr@4
|
266 |
_STLP_INLINE_LOOP _ForwardIter
|
williamr@4
|
267 |
remove(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
|
williamr@4
|
268 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
269 |
__first = find(__first, __last, __val);
|
williamr@4
|
270 |
if (__first == __last)
|
williamr@4
|
271 |
return __first;
|
williamr@4
|
272 |
else {
|
williamr@4
|
273 |
_ForwardIter __next = __first;
|
williamr@4
|
274 |
return remove_copy(++__next, __last, __first, __val);
|
williamr@4
|
275 |
}
|
williamr@4
|
276 |
}
|
williamr@4
|
277 |
|
williamr@4
|
278 |
template <class _ForwardIter, class _Predicate>
|
williamr@4
|
279 |
_STLP_INLINE_LOOP _ForwardIter
|
williamr@4
|
280 |
remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) {
|
williamr@4
|
281 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
282 |
__first = find_if(__first, __last, __pred);
|
williamr@4
|
283 |
if ( __first == __last )
|
williamr@4
|
284 |
return __first;
|
williamr@4
|
285 |
else {
|
williamr@4
|
286 |
_ForwardIter __next = __first;
|
williamr@4
|
287 |
return remove_copy_if(++__next, __last, __first, __pred);
|
williamr@4
|
288 |
}
|
williamr@4
|
289 |
}
|
williamr@4
|
290 |
|
williamr@4
|
291 |
// unique and unique_copy
|
williamr@4
|
292 |
template <class _InputIter, class _OutputIter>
|
williamr@4
|
293 |
_OutputIter unique_copy(_InputIter __first, _InputIter __last, _OutputIter __result);
|
williamr@4
|
294 |
|
williamr@4
|
295 |
template <class _InputIter, class _OutputIter, class _BinaryPredicate>
|
williamr@4
|
296 |
_OutputIter unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
|
williamr@4
|
297 |
_BinaryPredicate __binary_pred);
|
williamr@4
|
298 |
|
williamr@4
|
299 |
template <class _ForwardIter>
|
williamr@4
|
300 |
inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last) {
|
williamr@4
|
301 |
__first = adjacent_find(__first, __last);
|
williamr@4
|
302 |
return unique_copy(__first, __last, __first);
|
williamr@4
|
303 |
}
|
williamr@4
|
304 |
|
williamr@4
|
305 |
template <class _ForwardIter, class _BinaryPredicate>
|
williamr@4
|
306 |
inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
307 |
_BinaryPredicate __binary_pred) {
|
williamr@4
|
308 |
__first = adjacent_find(__first, __last, __binary_pred);
|
williamr@4
|
309 |
return unique_copy(__first, __last, __first, __binary_pred);
|
williamr@4
|
310 |
}
|
williamr@4
|
311 |
|
williamr@4
|
312 |
// reverse and reverse_copy, and their auxiliary functions
|
williamr@4
|
313 |
|
williamr@4
|
314 |
template <class _BidirectionalIter>
|
williamr@4
|
315 |
_STLP_INLINE_LOOP void
|
williamr@4
|
316 |
__reverse(_BidirectionalIter __first, _BidirectionalIter __last, const bidirectional_iterator_tag &) {
|
williamr@4
|
317 |
for(; __first != __last && __first != --__last; ++__first)
|
williamr@4
|
318 |
iter_swap(__first,__last);
|
williamr@4
|
319 |
}
|
williamr@4
|
320 |
|
williamr@4
|
321 |
|
williamr@4
|
322 |
template <class _RandomAccessIter>
|
williamr@4
|
323 |
_STLP_INLINE_LOOP void
|
williamr@4
|
324 |
__reverse(_RandomAccessIter __first, _RandomAccessIter __last, const random_access_iterator_tag &) {
|
williamr@4
|
325 |
for (; __first < __last; ++__first) iter_swap(__first, --__last);
|
williamr@4
|
326 |
}
|
williamr@4
|
327 |
|
williamr@4
|
328 |
template <class _BidirectionalIter>
|
williamr@4
|
329 |
inline void
|
williamr@4
|
330 |
reverse(_BidirectionalIter __first, _BidirectionalIter __last) {
|
williamr@4
|
331 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
332 |
__reverse(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _BidirectionalIter));
|
williamr@4
|
333 |
}
|
williamr@4
|
334 |
|
williamr@4
|
335 |
template <class _BidirectionalIter, class _OutputIter>
|
williamr@4
|
336 |
_STLP_INLINE_LOOP
|
williamr@4
|
337 |
_OutputIter reverse_copy(_BidirectionalIter __first,
|
williamr@4
|
338 |
_BidirectionalIter __last,
|
williamr@4
|
339 |
_OutputIter __result) {
|
williamr@4
|
340 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
341 |
while (__first != __last) {
|
williamr@4
|
342 |
--__last;
|
williamr@4
|
343 |
*__result = *__last;
|
williamr@4
|
344 |
++__result;
|
williamr@4
|
345 |
}
|
williamr@4
|
346 |
return __result;
|
williamr@4
|
347 |
}
|
williamr@4
|
348 |
|
williamr@4
|
349 |
// rotate and rotate_copy, and their auxiliary functions
|
williamr@4
|
350 |
|
williamr@4
|
351 |
template <class _EuclideanRingElement>
|
williamr@4
|
352 |
_STLP_INLINE_LOOP
|
williamr@4
|
353 |
_EuclideanRingElement __gcd(_EuclideanRingElement __m,
|
williamr@4
|
354 |
_EuclideanRingElement __n)
|
williamr@4
|
355 |
{
|
williamr@4
|
356 |
while (__n != 0) {
|
williamr@4
|
357 |
_EuclideanRingElement __t = __m % __n;
|
williamr@4
|
358 |
__m = __n;
|
williamr@4
|
359 |
__n = __t;
|
williamr@4
|
360 |
}
|
williamr@4
|
361 |
return __m;
|
williamr@4
|
362 |
}
|
williamr@4
|
363 |
|
williamr@4
|
364 |
template <class _ForwardIter>
|
williamr@4
|
365 |
_ForwardIter
|
williamr@4
|
366 |
rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last);
|
williamr@4
|
367 |
|
williamr@4
|
368 |
template <class _ForwardIter, class _OutputIter>
|
williamr@4
|
369 |
inline _OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle,
|
williamr@4
|
370 |
_ForwardIter __last, _OutputIter __result) {
|
williamr@4
|
371 |
return copy(__first, __middle, copy(__middle, __last, __result));
|
williamr@4
|
372 |
}
|
williamr@4
|
373 |
|
williamr@4
|
374 |
// random_shuffle
|
williamr@4
|
375 |
|
williamr@4
|
376 |
template <class _RandomAccessIter>
|
williamr@4
|
377 |
void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last);
|
williamr@4
|
378 |
|
williamr@4
|
379 |
template <class _RandomAccessIter, class _RandomNumberGenerator>
|
williamr@4
|
380 |
void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last,
|
williamr@4
|
381 |
_RandomNumberGenerator& __rand);
|
williamr@4
|
382 |
|
williamr@4
|
383 |
# ifndef _STLP_NO_EXTENSIONS
|
williamr@4
|
384 |
// random_sample and random_sample_n (extensions, not part of the standard).
|
williamr@4
|
385 |
|
williamr@4
|
386 |
template <class _ForwardIter, class _OutputIter, class _Distance>
|
williamr@4
|
387 |
_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
388 |
_OutputIter __stl_out, const _Distance __n);
|
williamr@4
|
389 |
|
williamr@4
|
390 |
template <class _ForwardIter, class _OutputIter, class _Distance,
|
williamr@4
|
391 |
class _RandomNumberGenerator>
|
williamr@4
|
392 |
_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
393 |
_OutputIter __stl_out, const _Distance __n,
|
williamr@4
|
394 |
_RandomNumberGenerator& __rand);
|
williamr@4
|
395 |
|
williamr@4
|
396 |
template <class _InputIter, class _RandomAccessIter>
|
williamr@4
|
397 |
_RandomAccessIter
|
williamr@4
|
398 |
random_sample(_InputIter __first, _InputIter __last,
|
williamr@4
|
399 |
_RandomAccessIter __out_first, _RandomAccessIter __out_last);
|
williamr@4
|
400 |
|
williamr@4
|
401 |
template <class _InputIter, class _RandomAccessIter,
|
williamr@4
|
402 |
class _RandomNumberGenerator>
|
williamr@4
|
403 |
_RandomAccessIter
|
williamr@4
|
404 |
random_sample(_InputIter __first, _InputIter __last,
|
williamr@4
|
405 |
_RandomAccessIter __out_first, _RandomAccessIter __out_last,
|
williamr@4
|
406 |
_RandomNumberGenerator& __rand);
|
williamr@4
|
407 |
|
williamr@4
|
408 |
# endif /* _STLP_NO_EXTENSIONS */
|
williamr@4
|
409 |
|
williamr@4
|
410 |
// partition, stable_partition, and their auxiliary functions
|
williamr@4
|
411 |
|
williamr@4
|
412 |
template <class _ForwardIter, class _Predicate>
|
williamr@4
|
413 |
_ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred);
|
williamr@4
|
414 |
|
williamr@4
|
415 |
|
williamr@4
|
416 |
template <class _ForwardIter, class _Predicate>
|
williamr@4
|
417 |
_ForwardIter
|
williamr@4
|
418 |
stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred);
|
williamr@4
|
419 |
|
williamr@4
|
420 |
// sort() and its auxiliary functions.
|
williamr@4
|
421 |
|
williamr@4
|
422 |
template <class _Size>
|
williamr@4
|
423 |
inline _Size __lg(_Size __n) {
|
williamr@4
|
424 |
_Size __k;
|
williamr@4
|
425 |
for (__k = 0; __n != 1; __n >>= 1) ++__k;
|
williamr@4
|
426 |
return __k;
|
williamr@4
|
427 |
}
|
williamr@4
|
428 |
|
williamr@4
|
429 |
template <class _RandomAccessIter>
|
williamr@4
|
430 |
void sort(_RandomAccessIter __first, _RandomAccessIter __last);
|
williamr@4
|
431 |
template <class _RandomAccessIter, class _Compare>
|
williamr@4
|
432 |
void sort(_RandomAccessIter __first, _RandomAccessIter __last, _Compare __comp);
|
williamr@4
|
433 |
|
williamr@4
|
434 |
// stable_sort() and its auxiliary functions.
|
williamr@4
|
435 |
template <class _RandomAccessIter>
|
williamr@4
|
436 |
void stable_sort(_RandomAccessIter __first,
|
williamr@4
|
437 |
_RandomAccessIter __last);
|
williamr@4
|
438 |
|
williamr@4
|
439 |
template <class _RandomAccessIter, class _Compare>
|
williamr@4
|
440 |
void stable_sort(_RandomAccessIter __first,
|
williamr@4
|
441 |
_RandomAccessIter __last, _Compare __comp);
|
williamr@4
|
442 |
|
williamr@4
|
443 |
// partial_sort, partial_sort_copy, and auxiliary functions.
|
williamr@4
|
444 |
|
williamr@4
|
445 |
template <class _RandomAccessIter>
|
williamr@4
|
446 |
void
|
williamr@4
|
447 |
partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle, _RandomAccessIter __last);
|
williamr@4
|
448 |
|
williamr@4
|
449 |
template <class _RandomAccessIter, class _Compare>
|
williamr@4
|
450 |
void
|
williamr@4
|
451 |
partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle,
|
williamr@4
|
452 |
_RandomAccessIter __last, _Compare __comp);
|
williamr@4
|
453 |
|
williamr@4
|
454 |
template <class _InputIter, class _RandomAccessIter>
|
williamr@4
|
455 |
_RandomAccessIter
|
williamr@4
|
456 |
partial_sort_copy(_InputIter __first, _InputIter __last,
|
williamr@4
|
457 |
_RandomAccessIter __result_first, _RandomAccessIter __result_last);
|
williamr@4
|
458 |
|
williamr@4
|
459 |
template <class _InputIter, class _RandomAccessIter, class _Compare>
|
williamr@4
|
460 |
_RandomAccessIter
|
williamr@4
|
461 |
partial_sort_copy(_InputIter __first, _InputIter __last,
|
williamr@4
|
462 |
_RandomAccessIter __result_first,
|
williamr@4
|
463 |
_RandomAccessIter __result_last, _Compare __comp);
|
williamr@4
|
464 |
|
williamr@4
|
465 |
// nth_element() and its auxiliary functions.
|
williamr@4
|
466 |
|
williamr@4
|
467 |
template <class _RandomAccessIter>
|
williamr@4
|
468 |
void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
|
williamr@4
|
469 |
_RandomAccessIter __last);
|
williamr@4
|
470 |
|
williamr@4
|
471 |
template <class _RandomAccessIter, class _Compare>
|
williamr@4
|
472 |
void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
|
williamr@4
|
473 |
_RandomAccessIter __last, _Compare __comp);
|
williamr@4
|
474 |
|
williamr@4
|
475 |
// auxiliary class for lower_bound, etc.
|
williamr@4
|
476 |
template <class _T1, class _T2>
|
williamr@4
|
477 |
struct __less_2 {
|
williamr@4
|
478 |
bool operator() (const _T1& __x, const _T2 __y) const { return __x < __y ; }
|
williamr@4
|
479 |
};
|
williamr@4
|
480 |
|
williamr@4
|
481 |
template <class _T1, class _T2>
|
williamr@4
|
482 |
__less_2<_T1,_T2> __less2(_T1*, _T2* ) { return __less_2<_T1, _T2>(); }
|
williamr@4
|
483 |
|
williamr@4
|
484 |
#ifdef _STLP_FUNCTION_PARTIAL_ORDER
|
williamr@4
|
485 |
template <class _Tp>
|
williamr@4
|
486 |
less<_Tp> __less2(_Tp*, _Tp* ) { return less<_Tp>(); }
|
williamr@4
|
487 |
#endif
|
williamr@4
|
488 |
|
williamr@4
|
489 |
// Binary search (lower_bound, upper_bound, equal_range, binary_search).
|
williamr@4
|
490 |
|
williamr@4
|
491 |
template <class _ForwardIter, class _Tp>
|
williamr@4
|
492 |
inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
493 |
const _Tp& __val) {
|
williamr@4
|
494 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
495 |
return __lower_bound(__first, __last, __val,
|
williamr@4
|
496 |
__less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
williamr@4
|
497 |
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
498 |
}
|
williamr@4
|
499 |
|
williamr@4
|
500 |
template <class _ForwardIter, class _Tp, class _Compare>
|
williamr@4
|
501 |
inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
502 |
const _Tp& __val, _Compare __comp) {
|
williamr@4
|
503 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
504 |
return __lower_bound(__first, __last, __val, __comp, _STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
505 |
}
|
williamr@4
|
506 |
|
williamr@4
|
507 |
template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
|
williamr@4
|
508 |
_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
509 |
const _Tp& __val, _Compare __comp, _Distance*);
|
williamr@4
|
510 |
|
williamr@4
|
511 |
template <class _ForwardIter, class _Tp>
|
williamr@4
|
512 |
inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
513 |
const _Tp& __val) {
|
williamr@4
|
514 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
515 |
return __upper_bound(__first, __last, __val,
|
williamr@4
|
516 |
__less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
williamr@4
|
517 |
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
518 |
}
|
williamr@4
|
519 |
|
williamr@4
|
520 |
template <class _ForwardIter, class _Tp, class _Compare>
|
williamr@4
|
521 |
inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
522 |
const _Tp& __val, _Compare __comp) {
|
williamr@4
|
523 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
524 |
return __upper_bound(__first, __last, __val, __comp,
|
williamr@4
|
525 |
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
526 |
}
|
williamr@4
|
527 |
|
williamr@4
|
528 |
template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
|
williamr@4
|
529 |
pair<_ForwardIter, _ForwardIter>
|
williamr@4
|
530 |
__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
williamr@4
|
531 |
_Compare __comp, _Distance*);
|
williamr@4
|
532 |
|
williamr@4
|
533 |
template <class _ForwardIter, class _Tp>
|
williamr@4
|
534 |
inline pair<_ForwardIter, _ForwardIter>
|
williamr@4
|
535 |
equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
|
williamr@4
|
536 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
537 |
return __equal_range(__first, __last, __val,
|
williamr@4
|
538 |
__less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
williamr@4
|
539 |
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
540 |
}
|
williamr@4
|
541 |
|
williamr@4
|
542 |
template <class _ForwardIter, class _Tp, class _Compare>
|
williamr@4
|
543 |
inline pair<_ForwardIter, _ForwardIter>
|
williamr@4
|
544 |
equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
williamr@4
|
545 |
_Compare __comp) {
|
williamr@4
|
546 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
547 |
return __equal_range(__first, __last, __val, __comp,
|
williamr@4
|
548 |
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
549 |
}
|
williamr@4
|
550 |
|
williamr@4
|
551 |
template <class _ForwardIter, class _Tp>
|
williamr@4
|
552 |
inline bool binary_search(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
553 |
const _Tp& __val) {
|
williamr@4
|
554 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
555 |
_ForwardIter __i = __lower_bound(__first, __last, __val,
|
williamr@4
|
556 |
__less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
williamr@4
|
557 |
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
558 |
return __i != __last && !(__val < *__i);
|
williamr@4
|
559 |
}
|
williamr@4
|
560 |
|
williamr@4
|
561 |
template <class _ForwardIter, class _Tp, class _Compare>
|
williamr@4
|
562 |
inline bool binary_search(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
563 |
const _Tp& __val,
|
williamr@4
|
564 |
_Compare __comp) {
|
williamr@4
|
565 |
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
williamr@4
|
566 |
_ForwardIter __i = __lower_bound(__first, __last, __val, __comp, _STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
williamr@4
|
567 |
return __i != __last && !__comp(__val, *__i);
|
williamr@4
|
568 |
}
|
williamr@4
|
569 |
|
williamr@4
|
570 |
// merge, with and without an explicitly supplied comparison function.
|
williamr@4
|
571 |
|
williamr@4
|
572 |
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
williamr@4
|
573 |
_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
574 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
575 |
_OutputIter __result);
|
williamr@4
|
576 |
|
williamr@4
|
577 |
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
williamr@4
|
578 |
class _Compare>
|
williamr@4
|
579 |
_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
580 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
581 |
_OutputIter __result, _Compare __comp);
|
williamr@4
|
582 |
|
williamr@4
|
583 |
|
williamr@4
|
584 |
// inplace_merge and its auxiliary functions.
|
williamr@4
|
585 |
|
williamr@4
|
586 |
|
williamr@4
|
587 |
template <class _BidirectionalIter>
|
williamr@4
|
588 |
void inplace_merge(_BidirectionalIter __first,
|
williamr@4
|
589 |
_BidirectionalIter __middle,
|
williamr@4
|
590 |
_BidirectionalIter __last) ;
|
williamr@4
|
591 |
|
williamr@4
|
592 |
template <class _BidirectionalIter, class _Compare>
|
williamr@4
|
593 |
void inplace_merge(_BidirectionalIter __first,
|
williamr@4
|
594 |
_BidirectionalIter __middle,
|
williamr@4
|
595 |
_BidirectionalIter __last, _Compare __comp);
|
williamr@4
|
596 |
|
williamr@4
|
597 |
// Set algorithms: includes, set_union, set_intersection, set_difference,
|
williamr@4
|
598 |
// set_symmetric_difference. All of these algorithms have the precondition
|
williamr@4
|
599 |
// that their input ranges are sorted and the postcondition that their output
|
williamr@4
|
600 |
// ranges are sorted.
|
williamr@4
|
601 |
|
williamr@4
|
602 |
template <class _InputIter1, class _InputIter2>
|
williamr@4
|
603 |
bool includes(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
604 |
_InputIter2 __first2, _InputIter2 __last2);
|
williamr@4
|
605 |
|
williamr@4
|
606 |
template <class _InputIter1, class _InputIter2, class _Compare>
|
williamr@4
|
607 |
bool includes(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
608 |
_InputIter2 __first2, _InputIter2 __last2, _Compare __comp);
|
williamr@4
|
609 |
|
williamr@4
|
610 |
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
williamr@4
|
611 |
_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
612 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
613 |
_OutputIter __result);
|
williamr@4
|
614 |
|
williamr@4
|
615 |
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
williamr@4
|
616 |
class _Compare>
|
williamr@4
|
617 |
_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
618 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
619 |
_OutputIter __result, _Compare __comp);
|
williamr@4
|
620 |
|
williamr@4
|
621 |
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
williamr@4
|
622 |
_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
623 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
624 |
_OutputIter __result);
|
williamr@4
|
625 |
|
williamr@4
|
626 |
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
williamr@4
|
627 |
class _Compare>
|
williamr@4
|
628 |
_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
629 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
630 |
_OutputIter __result, _Compare __comp);
|
williamr@4
|
631 |
|
williamr@4
|
632 |
|
williamr@4
|
633 |
|
williamr@4
|
634 |
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
williamr@4
|
635 |
_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
636 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
637 |
_OutputIter __result);
|
williamr@4
|
638 |
|
williamr@4
|
639 |
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
williamr@4
|
640 |
class _Compare>
|
williamr@4
|
641 |
_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
642 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
643 |
_OutputIter __result, _Compare __comp);
|
williamr@4
|
644 |
|
williamr@4
|
645 |
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
williamr@4
|
646 |
_OutputIter
|
williamr@4
|
647 |
set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
648 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
649 |
_OutputIter __result);
|
williamr@4
|
650 |
|
williamr@4
|
651 |
|
williamr@4
|
652 |
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
williamr@4
|
653 |
class _Compare>
|
williamr@4
|
654 |
_OutputIter
|
williamr@4
|
655 |
set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
|
williamr@4
|
656 |
_InputIter2 __first2, _InputIter2 __last2,
|
williamr@4
|
657 |
_OutputIter __result,
|
williamr@4
|
658 |
_Compare __comp);
|
williamr@4
|
659 |
|
williamr@4
|
660 |
|
williamr@4
|
661 |
// min_element and max_element, with and without an explicitly supplied
|
williamr@4
|
662 |
// comparison function.
|
williamr@4
|
663 |
|
williamr@4
|
664 |
template <class _ForwardIter>
|
williamr@4
|
665 |
_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last);
|
williamr@4
|
666 |
template <class _ForwardIter, class _Compare>
|
williamr@4
|
667 |
_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
668 |
_Compare __comp);
|
williamr@4
|
669 |
|
williamr@4
|
670 |
template <class _ForwardIter>
|
williamr@4
|
671 |
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last);
|
williamr@4
|
672 |
|
williamr@4
|
673 |
template <class _ForwardIter, class _Compare>
|
williamr@4
|
674 |
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
675 |
_Compare __comp);
|
williamr@4
|
676 |
|
williamr@4
|
677 |
// next_permutation and prev_permutation, with and without an explicitly
|
williamr@4
|
678 |
// supplied comparison function.
|
williamr@4
|
679 |
|
williamr@4
|
680 |
template <class _BidirectionalIter>
|
williamr@4
|
681 |
bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last);
|
williamr@4
|
682 |
|
williamr@4
|
683 |
template <class _BidirectionalIter, class _Compare>
|
williamr@4
|
684 |
bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
|
williamr@4
|
685 |
_Compare __comp);
|
williamr@4
|
686 |
|
williamr@4
|
687 |
|
williamr@4
|
688 |
template <class _BidirectionalIter>
|
williamr@4
|
689 |
bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last);
|
williamr@4
|
690 |
|
williamr@4
|
691 |
|
williamr@4
|
692 |
template <class _BidirectionalIter, class _Compare>
|
williamr@4
|
693 |
bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
|
williamr@4
|
694 |
_Compare __comp);
|
williamr@4
|
695 |
|
williamr@4
|
696 |
# ifndef _STLP_NO_EXTENSIONS
|
williamr@4
|
697 |
|
williamr@4
|
698 |
// is_heap, a predicate testing whether or not a range is
|
williamr@4
|
699 |
// a heap. This function is an extension, not part of the C++
|
williamr@4
|
700 |
// standard.
|
williamr@4
|
701 |
|
williamr@4
|
702 |
template <class _RandomAccessIter>
|
williamr@4
|
703 |
bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last);
|
williamr@4
|
704 |
|
williamr@4
|
705 |
template <class _RandomAccessIter, class _StrictWeakOrdering>
|
williamr@4
|
706 |
bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last,
|
williamr@4
|
707 |
_StrictWeakOrdering __comp);
|
williamr@4
|
708 |
|
williamr@4
|
709 |
|
williamr@4
|
710 |
// is_sorted, a predicated testing whether a range is sorted in
|
williamr@4
|
711 |
// nondescending order. This is an extension, not part of the C++
|
williamr@4
|
712 |
// standard.
|
williamr@4
|
713 |
template <class _ForwardIter, class _StrictWeakOrdering>
|
williamr@4
|
714 |
bool __is_sorted(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
715 |
_StrictWeakOrdering __comp);
|
williamr@4
|
716 |
|
williamr@4
|
717 |
template <class _ForwardIter>
|
williamr@4
|
718 |
inline bool is_sorted(_ForwardIter __first, _ForwardIter __last) {
|
williamr@4
|
719 |
return __is_sorted(__first, __last, __less(_STLP_VALUE_TYPE(__first, _ForwardIter)));
|
williamr@4
|
720 |
}
|
williamr@4
|
721 |
|
williamr@4
|
722 |
template <class _ForwardIter, class _StrictWeakOrdering>
|
williamr@4
|
723 |
inline bool is_sorted(_ForwardIter __first, _ForwardIter __last,
|
williamr@4
|
724 |
_StrictWeakOrdering __comp) {
|
williamr@4
|
725 |
return __is_sorted(__first, __last, __comp);
|
williamr@4
|
726 |
}
|
williamr@4
|
727 |
# endif
|
williamr@4
|
728 |
|
williamr@4
|
729 |
_STLP_END_NAMESPACE
|
williamr@4
|
730 |
|
williamr@4
|
731 |
# if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
williamr@4
|
732 |
# include <stl/_algo.c>
|
williamr@4
|
733 |
# endif
|
williamr@4
|
734 |
|
williamr@4
|
735 |
#endif /* _STLP_INTERNAL_ALGO_H */
|
williamr@4
|
736 |
|
williamr@4
|
737 |
// Local Variables:
|
williamr@4
|
738 |
// mode:C++
|
williamr@4
|
739 |
// End:
|
williamr@4
|
740 |
|