66 #ifdef __GXX_EXPERIMENTAL_CXX0X__
73 namespace std _GLIBCXX_VISIBILITY(default)
75 _GLIBCXX_BEGIN_NAMESPACE_VERSION
78 template<
typename _Iterator>
81 _Iterator __b, _Iterator __c)
84 __glibcxx_function_requires(_LessThanComparableConcept<
85 typename iterator_traits<_Iterator>::value_type>)
105 template<
typename _Iterator,
typename _Compare>
108 _Iterator __b, _Iterator __c,
112 __glibcxx_function_requires(_BinaryFunctionConcept<_Compare,
bool,
113 typename iterator_traits<_Iterator>::value_type,
114 typename iterator_traits<_Iterator>::value_type>)
116 if (__comp(*__a, *__b))
118 if (__comp(*__b, *__c))
120 else if (__comp(*__a, *__c))
125 else if (__comp(*__a, *__c))
127 else if (__comp(*__b, *__c))
136 template<
typename _InputIterator,
typename _Tp>
137 inline _InputIterator
138 __find(_InputIterator __first, _InputIterator __last,
141 while (__first != __last && !(*__first == __val))
147 template<
typename _InputIterator,
typename _Predicate>
148 inline _InputIterator
149 __find_if(_InputIterator __first, _InputIterator __last,
152 while (__first != __last && !
bool(__pred(*__first)))
158 template<
typename _RandomAccessIterator,
typename _Tp>
159 _RandomAccessIterator
160 __find(_RandomAccessIterator __first, _RandomAccessIterator __last,
163 typename iterator_traits<_RandomAccessIterator>::difference_type
164 __trip_count = (__last - __first) >> 2;
166 for (; __trip_count > 0; --__trip_count)
168 if (*__first == __val)
172 if (*__first == __val)
176 if (*__first == __val)
180 if (*__first == __val)
185 switch (__last - __first)
188 if (*__first == __val)
192 if (*__first == __val)
196 if (*__first == __val)
206 template<
typename _RandomAccessIterator,
typename _Predicate>
207 _RandomAccessIterator
208 __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
211 typename iterator_traits<_RandomAccessIterator>::difference_type
212 __trip_count = (__last - __first) >> 2;
214 for (; __trip_count > 0; --__trip_count)
216 if (__pred(*__first))
220 if (__pred(*__first))
224 if (__pred(*__first))
228 if (__pred(*__first))
233 switch (__last - __first)
236 if (__pred(*__first))
240 if (__pred(*__first))
244 if (__pred(*__first))
254 template<
typename _InputIterator,
typename _Predicate>
255 inline _InputIterator
259 while (__first != __last &&
bool(__pred(*__first)))
265 template<
typename _RandomAccessIterator,
typename _Predicate>
266 _RandomAccessIterator
270 typename iterator_traits<_RandomAccessIterator>::difference_type
271 __trip_count = (__last - __first) >> 2;
273 for (; __trip_count > 0; --__trip_count)
275 if (!
bool(__pred(*__first)))
279 if (!
bool(__pred(*__first)))
283 if (!
bool(__pred(*__first)))
287 if (!
bool(__pred(*__first)))
292 switch (__last - __first)
295 if (!
bool(__pred(*__first)))
299 if (!
bool(__pred(*__first)))
303 if (!
bool(__pred(*__first)))
313 template<
typename _InputIterator,
typename _Predicate>
314 inline _InputIterator
325 template<
typename _InputIterator,
typename _Predicate,
typename _Distance>
329 for (; __len; --__len, ++__first)
330 if (!
bool(__pred(*__first)))
353 template<
typename _ForwardIterator,
typename _Integer,
typename _Tp>
355 __search_n(_ForwardIterator __first, _ForwardIterator __last,
356 _Integer __count,
const _Tp& __val,
360 while (__first != __last)
362 typename iterator_traits<_ForwardIterator>::difference_type
364 _ForwardIterator __i = __first;
366 while (__i != __last && __n != 1 && *__i == __val)
385 template<
typename _RandomAccessIter,
typename _Integer,
typename _Tp>
387 __search_n(_RandomAccessIter __first, _RandomAccessIter __last,
388 _Integer __count,
const _Tp& __val,
392 typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
395 _DistanceType __tailSize = __last - __first;
396 const _DistanceType __pattSize = __count;
398 if (__tailSize < __pattSize)
401 const _DistanceType __skipOffset = __pattSize - 1;
402 _RandomAccessIter __lookAhead = __first + __skipOffset;
403 __tailSize -= __pattSize;
409 while (!(*__lookAhead == __val))
411 if (__tailSize < __pattSize)
413 __lookAhead += __pattSize;
414 __tailSize -= __pattSize;
416 _DistanceType __remainder = __skipOffset;
417 for (_RandomAccessIter __backTrack = __lookAhead - 1;
418 *__backTrack == __val; --__backTrack)
420 if (--__remainder == 0)
421 return (__lookAhead - __skipOffset);
423 if (__remainder > __tailSize)
425 __lookAhead += __remainder;
426 __tailSize -= __remainder;
438 template<
typename _ForwardIterator,
typename _Integer,
typename _Tp,
439 typename _BinaryPredicate>
441 __search_n(_ForwardIterator __first, _ForwardIterator __last,
442 _Integer __count,
const _Tp& __val,
445 while (__first != __last && !
bool(__binary_pred(*__first, __val)))
448 while (__first != __last)
450 typename iterator_traits<_ForwardIterator>::difference_type
452 _ForwardIterator __i = __first;
454 while (__i != __last && __n != 1 &&
bool(__binary_pred(*__i, __val)))
464 while (__first != __last
465 && !
bool(__binary_pred(*__first, __val)))
477 template<
typename _RandomAccessIter,
typename _Integer,
typename _Tp,
478 typename _BinaryPredicate>
480 __search_n(_RandomAccessIter __first, _RandomAccessIter __last,
481 _Integer __count,
const _Tp& __val,
485 typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
488 _DistanceType __tailSize = __last - __first;
489 const _DistanceType __pattSize = __count;
491 if (__tailSize < __pattSize)
494 const _DistanceType __skipOffset = __pattSize - 1;
495 _RandomAccessIter __lookAhead = __first + __skipOffset;
496 __tailSize -= __pattSize;
502 while (!
bool(__binary_pred(*__lookAhead, __val)))
504 if (__tailSize < __pattSize)
506 __lookAhead += __pattSize;
507 __tailSize -= __pattSize;
509 _DistanceType __remainder = __skipOffset;
510 for (_RandomAccessIter __backTrack = __lookAhead - 1;
511 __binary_pred(*__backTrack, __val); --__backTrack)
513 if (--__remainder == 0)
514 return (__lookAhead - __skipOffset);
516 if (__remainder > __tailSize)
518 __lookAhead += __remainder;
519 __tailSize -= __remainder;
524 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
526 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
527 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
528 forward_iterator_tag, forward_iterator_tag)
530 if (__first2 == __last2)
534 _ForwardIterator1 __result = __last1;
537 _ForwardIterator1 __new_result
539 if (__new_result == __last1)
543 __result = __new_result;
544 __first1 = __new_result;
551 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
552 typename _BinaryPredicate>
554 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
555 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
556 forward_iterator_tag, forward_iterator_tag,
557 _BinaryPredicate __comp)
559 if (__first2 == __last2)
563 _ForwardIterator1 __result = __last1;
566 _ForwardIterator1 __new_result
569 if (__new_result == __last1)
573 __result = __new_result;
574 __first1 = __new_result;
582 template<
typename _B
idirectionalIterator1,
typename _B
idirectionalIterator2>
583 _BidirectionalIterator1
584 __find_end(_BidirectionalIterator1 __first1,
585 _BidirectionalIterator1 __last1,
586 _BidirectionalIterator2 __first2,
587 _BidirectionalIterator2 __last2,
588 bidirectional_iterator_tag, bidirectional_iterator_tag)
591 __glibcxx_function_requires(_BidirectionalIteratorConcept<
592 _BidirectionalIterator1>)
593 __glibcxx_function_requires(_BidirectionalIteratorConcept<
594 _BidirectionalIterator2>)
596 typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1;
597 typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2;
599 _RevIterator1 __rlast1(__first1);
600 _RevIterator2 __rlast2(__first2);
601 _RevIterator1 __rresult = _GLIBCXX_STD_A::search(_RevIterator1(__last1),
603 _RevIterator2(__last2),
606 if (__rresult == __rlast1)
610 _BidirectionalIterator1 __result = __rresult.base();
616 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
617 typename _BinaryPredicate>
618 _BidirectionalIterator1
619 __find_end(_BidirectionalIterator1 __first1,
620 _BidirectionalIterator1 __last1,
621 _BidirectionalIterator2 __first2,
622 _BidirectionalIterator2 __last2,
623 bidirectional_iterator_tag, bidirectional_iterator_tag,
624 _BinaryPredicate __comp)
627 __glibcxx_function_requires(_BidirectionalIteratorConcept<
628 _BidirectionalIterator1>)
629 __glibcxx_function_requires(_BidirectionalIteratorConcept<
630 _BidirectionalIterator2>)
632 typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1;
633 typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2;
635 _RevIterator1 __rlast1(__first1);
636 _RevIterator2 __rlast2(__first2);
637 _RevIterator1 __rresult = std::search(_RevIterator1(__last1), __rlast1,
638 _RevIterator2(__last2), __rlast2,
641 if (__rresult == __rlast1)
645 _BidirectionalIterator1 __result = __rresult.base();
677 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
678 inline _ForwardIterator1
679 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
680 _ForwardIterator2 __first2, _ForwardIterator2 __last2)
683 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
684 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
685 __glibcxx_function_requires(_EqualOpConcept<
686 typename iterator_traits<_ForwardIterator1>::value_type,
687 typename iterator_traits<_ForwardIterator2>::value_type>)
688 __glibcxx_requires_valid_range(__first1, __last1);
689 __glibcxx_requires_valid_range(__first2, __last2);
691 return std::__find_end(__first1, __last1, __first2, __last2,
724 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
725 typename _BinaryPredicate>
726 inline _ForwardIterator1
727 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
728 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
729 _BinaryPredicate __comp)
732 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
733 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
734 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
735 typename iterator_traits<_ForwardIterator1>::value_type,
736 typename iterator_traits<_ForwardIterator2>::value_type>)
737 __glibcxx_requires_valid_range(__first1, __last1);
738 __glibcxx_requires_valid_range(__first2, __last2);
740 return std::__find_end(__first1, __last1, __first2, __last2,
746 #ifdef __GXX_EXPERIMENTAL_CXX0X__
759 template<
typename _InputIterator,
typename _Predicate>
761 all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
776 template<
typename _InputIterator,
typename _Predicate>
778 none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
794 template<
typename _InputIterator,
typename _Predicate>
796 any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
809 template<
typename _InputIterator,
typename _Predicate>
810 inline _InputIterator
811 find_if_not(_InputIterator __first, _InputIterator __last,
815 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
816 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
817 typename iterator_traits<_InputIterator>::value_type>)
818 __glibcxx_requires_valid_range(__first, __last);
832 template<
typename _InputIterator,
typename _Predicate>
834 is_partitioned(_InputIterator __first, _InputIterator __last,
850 template<
typename _ForwardIterator,
typename _Predicate>
852 partition_point(_ForwardIterator __first, _ForwardIterator __last,
856 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
857 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
858 typename iterator_traits<_ForwardIterator>::value_type>)
861 __glibcxx_requires_valid_range(__first, __last);
863 typedef typename iterator_traits<_ForwardIterator>::difference_type
867 _DistanceType __half;
868 _ForwardIterator __middle;
875 if (__pred(*__middle))
879 __len = __len - __half - 1;
903 template<
typename _InputIterator,
typename _OutputIterator,
typename _Tp>
905 remove_copy(_InputIterator __first, _InputIterator __last,
906 _OutputIterator __result,
const _Tp& __value)
909 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
910 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
911 typename iterator_traits<_InputIterator>::value_type>)
912 __glibcxx_function_requires(_EqualOpConcept<
913 typename iterator_traits<_InputIterator>::value_type, _Tp>)
914 __glibcxx_requires_valid_range(__first, __last);
916 for (; __first != __last; ++__first)
917 if (!(*__first == __value))
919 *__result = *__first;
940 template<
typename _InputIterator,
typename _OutputIterator,
943 remove_copy_if(_InputIterator __first, _InputIterator __last,
944 _OutputIterator __result, _Predicate __pred)
947 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
948 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
949 typename iterator_traits<_InputIterator>::value_type>)
950 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
951 typename iterator_traits<_InputIterator>::value_type>)
952 __glibcxx_requires_valid_range(__first, __last);
954 for (; __first != __last; ++__first)
955 if (!
bool(__pred(*__first)))
957 *__result = *__first;
963 #ifdef __GXX_EXPERIMENTAL_CXX0X__
979 template<
typename _InputIterator,
typename _OutputIterator,
982 copy_if(_InputIterator __first, _InputIterator __last,
983 _OutputIterator __result, _Predicate __pred)
986 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
987 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
988 typename iterator_traits<_InputIterator>::value_type>)
989 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
990 typename iterator_traits<_InputIterator>::value_type>)
991 __glibcxx_requires_valid_range(__first, __last);
993 for (; __first != __last; ++__first)
994 if (__pred(*__first))
996 *__result = *__first;
1003 template<
typename _InputIterator,
typename _Size,
typename _OutputIterator>
1005 __copy_n(_InputIterator __first, _Size __n,
1006 _OutputIterator __result, input_iterator_tag)
1012 *__result = *__first;
1023 template<
typename _RandomAccessIterator,
typename _Size,
1024 typename _OutputIterator>
1025 inline _OutputIterator
1026 __copy_n(_RandomAccessIterator __first, _Size __n,
1027 _OutputIterator __result, random_access_iterator_tag)
1028 {
return std::copy(__first, __first + __n, __result); }
1043 template<
typename _InputIterator,
typename _Size,
typename _OutputIterator>
1044 inline _OutputIterator
1045 copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
1048 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
1049 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1050 typename iterator_traits<_InputIterator>::value_type>)
1052 return std::__copy_n(__first, __n, __result,
1071 template<
typename _InputIterator,
typename _OutputIterator1,
1072 typename _OutputIterator2,
typename _Predicate>
1073 pair<_OutputIterator1, _OutputIterator2>
1074 partition_copy(_InputIterator __first, _InputIterator __last,
1075 _OutputIterator1 __out_true, _OutputIterator2 __out_false,
1079 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
1080 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator1,
1081 typename iterator_traits<_InputIterator>::value_type>)
1082 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator2,
1083 typename iterator_traits<_InputIterator>::value_type>)
1084 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
1085 typename iterator_traits<_InputIterator>::value_type>)
1086 __glibcxx_requires_valid_range(__first, __last);
1088 for (; __first != __last; ++__first)
1089 if (__pred(*__first))
1091 *__out_true = *__first;
1096 *__out_false = *__first;
1121 template<
typename _ForwardIterator,
typename _Tp>
1123 remove(_ForwardIterator __first, _ForwardIterator __last,
1127 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1129 __glibcxx_function_requires(_EqualOpConcept<
1130 typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
1131 __glibcxx_requires_valid_range(__first, __last);
1134 if(__first == __last)
1136 _ForwardIterator __result = __first;
1138 for(; __first != __last; ++__first)
1139 if(!(*__first == __value))
1141 *__result = _GLIBCXX_MOVE(*__first);
1164 template<
typename _ForwardIterator,
typename _Predicate>
1166 remove_if(_ForwardIterator __first, _ForwardIterator __last,
1170 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1172 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
1173 typename iterator_traits<_ForwardIterator>::value_type>)
1174 __glibcxx_requires_valid_range(__first, __last);
1177 if(__first == __last)
1179 _ForwardIterator __result = __first;
1181 for(; __first != __last; ++__first)
1182 if(!
bool(__pred(*__first)))
1184 *__result = _GLIBCXX_MOVE(*__first);
1204 template<
typename _ForwardIterator>
1206 unique(_ForwardIterator __first, _ForwardIterator __last)
1209 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1211 __glibcxx_function_requires(_EqualityComparableConcept<
1212 typename iterator_traits<_ForwardIterator>::value_type>)
1213 __glibcxx_requires_valid_range(__first, __last);
1217 if (__first == __last)
1221 _ForwardIterator __dest = __first;
1223 while (++__first != __last)
1224 if (!(*__dest == *__first))
1225 *++__dest = _GLIBCXX_MOVE(*__first);
1244 template<
typename _ForwardIterator,
typename _BinaryPredicate>
1246 unique(_ForwardIterator __first, _ForwardIterator __last,
1247 _BinaryPredicate __binary_pred)
1250 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1252 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1253 typename iterator_traits<_ForwardIterator>::value_type,
1254 typename iterator_traits<_ForwardIterator>::value_type>)
1255 __glibcxx_requires_valid_range(__first, __last);
1259 if (__first == __last)
1263 _ForwardIterator __dest = __first;
1265 while (++__first != __last)
1266 if (!
bool(__binary_pred(*__dest, *__first)))
1267 *++__dest = _GLIBCXX_MOVE(*__first);
1276 template<
typename _ForwardIterator,
typename _OutputIterator>
1279 _OutputIterator __result,
1283 _ForwardIterator __next = __first;
1284 *__result = *__first;
1285 while (++__next != __last)
1286 if (!(*__first == *__next))
1289 *++__result = *__first;
1299 template<
typename _InputIterator,
typename _OutputIterator>
1302 _OutputIterator __result,
1306 typename iterator_traits<_InputIterator>::value_type __value = *__first;
1307 *__result = __value;
1308 while (++__first != __last)
1309 if (!(__value == *__first))
1312 *++__result = __value;
1322 template<
typename _InputIterator,
typename _ForwardIterator>
1325 _ForwardIterator __result,
1329 *__result = *__first;
1330 while (++__first != __last)
1331 if (!(*__result == *__first))
1332 *++__result = *__first;
1342 template<
typename _ForwardIterator,
typename _OutputIterator,
1343 typename _BinaryPredicate>
1346 _OutputIterator __result, _BinaryPredicate __binary_pred,
1350 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1351 typename iterator_traits<_ForwardIterator>::value_type,
1352 typename iterator_traits<_ForwardIterator>::value_type>)
1354 _ForwardIterator __next = __first;
1355 *__result = *__first;
1356 while (++__next != __last)
1357 if (!
bool(__binary_pred(*__first, *__next)))
1360 *++__result = *__first;
1371 template<
typename _InputIterator,
typename _OutputIterator,
1372 typename _BinaryPredicate>
1375 _OutputIterator __result, _BinaryPredicate __binary_pred,
1379 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1380 typename iterator_traits<_InputIterator>::value_type,
1381 typename iterator_traits<_InputIterator>::value_type>)
1383 typename iterator_traits<_InputIterator>::value_type __value = *__first;
1384 *__result = __value;
1385 while (++__first != __last)
1386 if (!
bool(__binary_pred(__value, *__first)))
1389 *++__result = __value;
1400 template<
typename _InputIterator,
typename _ForwardIterator,
1401 typename _BinaryPredicate>
1404 _ForwardIterator __result, _BinaryPredicate __binary_pred,
1408 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1409 typename iterator_traits<_ForwardIterator>::value_type,
1410 typename iterator_traits<_InputIterator>::value_type>)
1412 *__result = *__first;
1413 while (++__first != __last)
1414 if (!
bool(__binary_pred(*__result, *__first)))
1415 *++__result = *__first;
1424 template<
typename _B
idirectionalIterator>
1426 __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last,
1430 if (__first == __last || __first == --__last)
1444 template<
typename _RandomAccessIterator>
1446 __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last,
1449 if (__first == __last)
1452 while (__first < __last)
1472 template<
typename _B
idirectionalIterator>
1474 reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
1477 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
1478 _BidirectionalIterator>)
1479 __glibcxx_requires_valid_range(__first, __last);
1499 template<
typename _B
idirectionalIterator,
typename _OutputIterator>
1501 reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last,
1502 _OutputIterator __result)
1505 __glibcxx_function_requires(_BidirectionalIteratorConcept<
1506 _BidirectionalIterator>)
1507 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1508 typename iterator_traits<_BidirectionalIterator>::value_type>)
1509 __glibcxx_requires_valid_range(__first, __last);
1511 while (__first != __last)
1514 *__result = *__last;
1524 template<
typename _Eucl
ideanRingElement>
1525 _EuclideanRingElement
1526 __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
1530 _EuclideanRingElement __t = __m % __n;
1538 template<
typename _ForwardIterator>
1541 _ForwardIterator __middle,
1542 _ForwardIterator __last,
1545 if (__first == __middle || __last == __middle)
1548 _ForwardIterator __first2 = __middle;
1554 if (__first == __middle)
1555 __middle = __first2;
1557 while (__first2 != __last);
1559 __first2 = __middle;
1561 while (__first2 != __last)
1566 if (__first == __middle)
1567 __middle = __first2;
1568 else if (__first2 == __last)
1569 __first2 = __middle;
1574 template<
typename _B
idirectionalIterator>
1577 _BidirectionalIterator __middle,
1578 _BidirectionalIterator __last,
1582 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
1583 _BidirectionalIterator>)
1585 if (__first == __middle || __last == __middle)
1591 while (__first != __middle && __middle != __last)
1597 if (__first == __middle)
1604 template<
typename _RandomAccessIterator>
1607 _RandomAccessIterator __middle,
1608 _RandomAccessIterator __last,
1612 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
1613 _RandomAccessIterator>)
1615 if (__first == __middle || __last == __middle)
1618 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
1620 typedef typename iterator_traits<_RandomAccessIterator>::value_type
1623 _Distance __n = __last - __first;
1624 _Distance __k = __middle - __first;
1626 if (__k == __n - __k)
1632 _RandomAccessIterator __p = __first;
1636 if (__k < __n - __k)
1638 if (__is_pod(_ValueType) && __k == 1)
1640 _ValueType __t = _GLIBCXX_MOVE(*__p);
1641 _GLIBCXX_MOVE3(__p + 1, __p + __n, __p);
1642 *(__p + __n - 1) = _GLIBCXX_MOVE(__t);
1645 _RandomAccessIterator __q = __p + __k;
1646 for (_Distance __i = 0; __i < __n - __k; ++ __i)
1655 std::swap(__n, __k);
1661 if (__is_pod(_ValueType) && __k == 1)
1663 _ValueType __t = _GLIBCXX_MOVE(*(__p + __n - 1));
1664 _GLIBCXX_MOVE_BACKWARD3(__p, __p + __n - 1, __p + __n);
1665 *__p = _GLIBCXX_MOVE(__t);
1668 _RandomAccessIterator __q = __p + __n;
1670 for (_Distance __i = 0; __i < __n - __k; ++ __i)
1679 std::swap(__n, __k);
1705 template<
typename _ForwardIterator>
1707 rotate(_ForwardIterator __first, _ForwardIterator __middle,
1708 _ForwardIterator __last)
1711 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1713 __glibcxx_requires_valid_range(__first, __middle);
1714 __glibcxx_requires_valid_range(__middle, __last);
1716 typedef typename iterator_traits<_ForwardIterator>::iterator_category
1741 template<
typename _ForwardIterator,
typename _OutputIterator>
1743 rotate_copy(_ForwardIterator __first, _ForwardIterator __middle,
1744 _ForwardIterator __last, _OutputIterator __result)
1747 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1748 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1749 typename iterator_traits<_ForwardIterator>::value_type>)
1750 __glibcxx_requires_valid_range(__first, __middle);
1751 __glibcxx_requires_valid_range(__middle, __last);
1753 return std::copy(__first, __middle,
1754 std::copy(__middle, __last, __result));
1758 template<
typename _ForwardIterator,
typename _Predicate>
1763 if (__first == __last)
1766 while (__pred(*__first))
1767 if (++__first == __last)
1770 _ForwardIterator __next = __first;
1772 while (++__next != __last)
1773 if (__pred(*__next))
1783 template<
typename _B
idirectionalIterator,
typename _Predicate>
1784 _BidirectionalIterator
1785 __partition(_BidirectionalIterator __first, _BidirectionalIterator __last,
1791 if (__first == __last)
1793 else if (__pred(*__first))
1799 if (__first == __last)
1801 else if (!
bool(__pred(*__last)))
1815 template<
typename _ForwardIterator,
typename _Predicate,
typename _Distance>
1818 _Predicate __pred, _Distance __len)
1822 _ForwardIterator __middle = __first;
1824 _ForwardIterator __left_split =
1828 _Distance __right_len = __len - __len / 2;
1829 _ForwardIterator __right_split =
1835 std::rotate(__left_split, __middle, __right_split);
1837 return __left_split;
1846 template<
typename _ForwardIterator,
typename _Pointer,
typename _Predicate,
1850 _ForwardIterator __last,
1851 _Predicate __pred, _Distance __len,
1853 _Distance __buffer_size)
1855 if (__len <= __buffer_size)
1857 _ForwardIterator __result1 = __first;
1858 _Pointer __result2 = __buffer;
1862 *__result2 = _GLIBCXX_MOVE(*__first);
1865 for (; __first != __last; ++__first)
1866 if (__pred(*__first))
1868 *__result1 = _GLIBCXX_MOVE(*__first);
1873 *__result2 = _GLIBCXX_MOVE(*__first);
1876 _GLIBCXX_MOVE3(__buffer, __result2, __result1);
1881 _ForwardIterator __middle = __first;
1883 _ForwardIterator __left_split =
1885 __len / 2, __buffer,
1889 _Distance __right_len = __len - __len / 2;
1890 _ForwardIterator __right_split =
1896 __buffer, __buffer_size);
1897 std::rotate(__left_split, __middle, __right_split);
1899 return __left_split;
1920 template<
typename _ForwardIterator,
typename _Predicate>
1922 stable_partition(_ForwardIterator __first, _ForwardIterator __last,
1926 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1928 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
1929 typename iterator_traits<_ForwardIterator>::value_type>)
1930 __glibcxx_requires_valid_range(__first, __last);
1934 if (__first == __last)
1938 typedef typename iterator_traits<_ForwardIterator>::value_type
1940 typedef typename iterator_traits<_ForwardIterator>::difference_type
1945 if (__buf.
size() > 0)
1950 _DistanceType(__buf.
size()));
1959 template<
typename _RandomAccessIterator>
1962 _RandomAccessIterator __middle,
1963 _RandomAccessIterator __last)
1966 for (_RandomAccessIterator __i = __middle; __i < __last; ++__i)
1967 if (*__i < *__first)
1968 std::__pop_heap(__first, __middle, __i);
1972 template<
typename _RandomAccessIterator,
typename _Compare>
1975 _RandomAccessIterator __middle,
1976 _RandomAccessIterator __last, _Compare __comp)
1979 for (_RandomAccessIterator __i = __middle; __i < __last; ++__i)
1980 if (__comp(*__i, *__first))
1981 std::__pop_heap(__first, __middle, __i, __comp);
2004 template<
typename _InputIterator,
typename _RandomAccessIterator>
2005 _RandomAccessIterator
2006 partial_sort_copy(_InputIterator __first, _InputIterator __last,
2007 _RandomAccessIterator __result_first,
2008 _RandomAccessIterator __result_last)
2010 typedef typename iterator_traits<_InputIterator>::value_type
2012 typedef typename iterator_traits<_RandomAccessIterator>::value_type
2014 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
2018 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
2019 __glibcxx_function_requires(_ConvertibleConcept<_InputValueType,
2021 __glibcxx_function_requires(_LessThanOpConcept<_InputValueType,
2023 __glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>)
2024 __glibcxx_requires_valid_range(__first, __last);
2025 __glibcxx_requires_valid_range(__result_first, __result_last);
2027 if (__result_first == __result_last)
2028 return __result_last;
2029 _RandomAccessIterator __result_real_last = __result_first;
2030 while(__first != __last && __result_real_last != __result_last)
2032 *__result_real_last = *__first;
2033 ++__result_real_last;
2037 while (__first != __last)
2039 if (*__first < *__result_first)
2040 std::__adjust_heap(__result_first, _DistanceType(0),
2041 _DistanceType(__result_real_last
2043 _InputValueType(*__first));
2047 return __result_real_last;
2070 template<
typename _InputIterator,
typename _RandomAccessIterator,
typename _Compare>
2071 _RandomAccessIterator
2072 partial_sort_copy(_InputIterator __first, _InputIterator __last,
2073 _RandomAccessIterator __result_first,
2074 _RandomAccessIterator __result_last,
2077 typedef typename iterator_traits<_InputIterator>::value_type
2079 typedef typename iterator_traits<_RandomAccessIterator>::value_type
2081 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
2085 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
2086 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
2087 _RandomAccessIterator>)
2088 __glibcxx_function_requires(_ConvertibleConcept<_InputValueType,
2090 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2091 _InputValueType, _OutputValueType>)
2092 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2093 _OutputValueType, _OutputValueType>)
2094 __glibcxx_requires_valid_range(__first, __last);
2095 __glibcxx_requires_valid_range(__result_first, __result_last);
2097 if (__result_first == __result_last)
2098 return __result_last;
2099 _RandomAccessIterator __result_real_last = __result_first;
2100 while(__first != __last && __result_real_last != __result_last)
2102 *__result_real_last = *__first;
2103 ++__result_real_last;
2107 while (__first != __last)
2109 if (__comp(*__first, *__result_first))
2110 std::__adjust_heap(__result_first, _DistanceType(0),
2111 _DistanceType(__result_real_last
2113 _InputValueType(*__first),
2118 return __result_real_last;
2122 template<
typename _RandomAccessIterator>
2126 typename iterator_traits<_RandomAccessIterator>::value_type
2127 __val = _GLIBCXX_MOVE(*__last);
2128 _RandomAccessIterator __next = __last;
2130 while (__val < *__next)
2132 *__last = _GLIBCXX_MOVE(*__next);
2136 *__last = _GLIBCXX_MOVE(__val);
2140 template<
typename _RandomAccessIterator,
typename _Compare>
2145 typename iterator_traits<_RandomAccessIterator>::value_type
2146 __val = _GLIBCXX_MOVE(*__last);
2147 _RandomAccessIterator __next = __last;
2149 while (__comp(__val, *__next))
2151 *__last = _GLIBCXX_MOVE(*__next);
2155 *__last = _GLIBCXX_MOVE(__val);
2159 template<
typename _RandomAccessIterator>
2162 _RandomAccessIterator __last)
2164 if (__first == __last)
2167 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
2169 if (*__i < *__first)
2171 typename iterator_traits<_RandomAccessIterator>::value_type
2172 __val = _GLIBCXX_MOVE(*__i);
2173 _GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1);
2174 *__first = _GLIBCXX_MOVE(__val);
2182 template<
typename _RandomAccessIterator,
typename _Compare>
2185 _RandomAccessIterator __last, _Compare __comp)
2187 if (__first == __last)
return;
2189 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
2191 if (__comp(*__i, *__first))
2193 typename iterator_traits<_RandomAccessIterator>::value_type
2194 __val = _GLIBCXX_MOVE(*__i);
2195 _GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1);
2196 *__first = _GLIBCXX_MOVE(__val);
2204 template<
typename _RandomAccessIterator>
2207 _RandomAccessIterator __last)
2209 typedef typename iterator_traits<_RandomAccessIterator>::value_type
2212 for (_RandomAccessIterator __i = __first; __i != __last; ++__i)
2217 template<
typename _RandomAccessIterator,
typename _Compare>
2220 _RandomAccessIterator __last, _Compare __comp)
2222 typedef typename iterator_traits<_RandomAccessIterator>::value_type
2225 for (_RandomAccessIterator __i = __first; __i != __last; ++__i)
2233 enum { _S_threshold = 16 };
2236 template<
typename _RandomAccessIterator>
2239 _RandomAccessIterator __last)
2241 if (__last - __first >
int(_S_threshold))
2251 template<
typename _RandomAccessIterator,
typename _Compare>
2254 _RandomAccessIterator __last, _Compare __comp)
2256 if (__last - __first >
int(_S_threshold))
2267 template<
typename _RandomAccessIterator,
typename _Tp>
2268 _RandomAccessIterator
2270 _RandomAccessIterator __last,
const _Tp& __pivot)
2274 while (*__first < __pivot)
2277 while (__pivot < *__last)
2279 if (!(__first < __last))
2287 template<
typename _RandomAccessIterator,
typename _Tp,
typename _Compare>
2288 _RandomAccessIterator
2290 _RandomAccessIterator __last,
2291 const _Tp& __pivot, _Compare __comp)
2295 while (__comp(*__first, __pivot))
2298 while (__comp(__pivot, *__last))
2300 if (!(__first < __last))
2308 template<
typename _RandomAccessIterator>
2309 inline _RandomAccessIterator
2311 _RandomAccessIterator __last)
2313 _RandomAccessIterator __mid = __first + (__last - __first) / 2;
2320 template<
typename _RandomAccessIterator,
typename _Compare>
2321 inline _RandomAccessIterator
2323 _RandomAccessIterator __last, _Compare __comp)
2325 _RandomAccessIterator __mid = __first + (__last - __first) / 2;
2332 template<
typename _RandomAccessIterator,
typename _Size>
2335 _RandomAccessIterator __last,
2336 _Size __depth_limit)
2338 while (__last - __first >
int(_S_threshold))
2340 if (__depth_limit == 0)
2346 _RandomAccessIterator __cut =
2354 template<
typename _RandomAccessIterator,
typename _Size,
typename _Compare>
2357 _RandomAccessIterator __last,
2358 _Size __depth_limit, _Compare __comp)
2360 while (__last - __first >
int(_S_threshold))
2362 if (__depth_limit == 0)
2368 _RandomAccessIterator __cut =
2377 template<
typename _RandomAccessIterator,
typename _Size>
2379 __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
2380 _RandomAccessIterator __last, _Size __depth_limit)
2382 typedef typename iterator_traits<_RandomAccessIterator>::value_type
2385 while (__last - __first > 3)
2387 if (__depth_limit == 0)
2392 std::iter_swap(__first, __nth);
2396 _RandomAccessIterator __cut =
2406 template<
typename _RandomAccessIterator,
typename _Size,
typename _Compare>
2408 __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
2409 _RandomAccessIterator __last, _Size __depth_limit,
2412 typedef typename iterator_traits<_RandomAccessIterator>::value_type
2415 while (__last - __first > 3)
2417 if (__depth_limit == 0)
2425 _RandomAccessIterator __cut =
2455 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2457 lower_bound(_ForwardIterator __first, _ForwardIterator __last,
2458 const _Tp& __val, _Compare __comp)
2460 typedef typename iterator_traits<_ForwardIterator>::value_type
2462 typedef typename iterator_traits<_ForwardIterator>::difference_type
2466 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2467 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2469 __glibcxx_requires_partitioned_lower_pred(__first, __last,
2476 _DistanceType __half = __len >> 1;
2477 _ForwardIterator __middle = __first;
2479 if (__comp(*__middle, __val))
2483 __len = __len - __half - 1;
2502 template<
typename _ForwardIterator,
typename _Tp>
2504 upper_bound(_ForwardIterator __first, _ForwardIterator __last,
2507 typedef typename iterator_traits<_ForwardIterator>::value_type
2509 typedef typename iterator_traits<_ForwardIterator>::difference_type
2513 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2514 __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>)
2515 __glibcxx_requires_partitioned_upper(__first, __last, __val);
2521 _DistanceType __half = __len >> 1;
2522 _ForwardIterator __middle = __first;
2524 if (__val < *__middle)
2530 __len = __len - __half - 1;
2551 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2553 upper_bound(_ForwardIterator __first, _ForwardIterator __last,
2554 const _Tp& __val, _Compare __comp)
2556 typedef typename iterator_traits<_ForwardIterator>::value_type
2558 typedef typename iterator_traits<_ForwardIterator>::difference_type
2562 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2563 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2565 __glibcxx_requires_partitioned_upper_pred(__first, __last,
2572 _DistanceType __half = __len >> 1;
2573 _ForwardIterator __middle = __first;
2575 if (__comp(__val, *__middle))
2581 __len = __len - __half - 1;
2604 template<
typename _ForwardIterator,
typename _Tp>
2605 pair<_ForwardIterator, _ForwardIterator>
2606 equal_range(_ForwardIterator __first, _ForwardIterator __last,
2609 typedef typename iterator_traits<_ForwardIterator>::value_type
2611 typedef typename iterator_traits<_ForwardIterator>::difference_type
2615 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2616 __glibcxx_function_requires(_LessThanOpConcept<_ValueType, _Tp>)
2617 __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>)
2618 __glibcxx_requires_partitioned_lower(__first, __last, __val);
2619 __glibcxx_requires_partitioned_upper(__first, __last, __val);
2625 _DistanceType __half = __len >> 1;
2626 _ForwardIterator __middle = __first;
2628 if (*__middle < __val)
2632 __len = __len - __half - 1;
2634 else if (__val < *__middle)
2666 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2667 pair<_ForwardIterator, _ForwardIterator>
2668 equal_range(_ForwardIterator __first, _ForwardIterator __last,
2669 const _Tp& __val, _Compare __comp)
2671 typedef typename iterator_traits<_ForwardIterator>::value_type
2673 typedef typename iterator_traits<_ForwardIterator>::difference_type
2677 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2678 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2680 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2682 __glibcxx_requires_partitioned_lower_pred(__first, __last,
2684 __glibcxx_requires_partitioned_upper_pred(__first, __last,
2691 _DistanceType __half = __len >> 1;
2692 _ForwardIterator __middle = __first;
2694 if (__comp(*__middle, __val))
2698 __len = __len - __half - 1;
2700 else if (__comp(__val, *__middle))
2727 template<
typename _ForwardIterator,
typename _Tp>
2729 binary_search(_ForwardIterator __first, _ForwardIterator __last,
2732 typedef typename iterator_traits<_ForwardIterator>::value_type
2736 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2737 __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>)
2738 __glibcxx_requires_partitioned_lower(__first, __last, __val);
2739 __glibcxx_requires_partitioned_upper(__first, __last, __val);
2742 return __i != __last && !(__val < *__i);
2760 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2762 binary_search(_ForwardIterator __first, _ForwardIterator __last,
2763 const _Tp& __val, _Compare __comp)
2765 typedef typename iterator_traits<_ForwardIterator>::value_type
2769 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2770 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2772 __glibcxx_requires_partitioned_lower_pred(__first, __last,
2774 __glibcxx_requires_partitioned_upper_pred(__first, __last,
2778 return __i != __last && !bool(__comp(__val, *__i));
2784 template<
typename _InputIterator1,
typename _InputIterator2,
2785 typename _OutputIterator>
2788 _InputIterator2 __first2, _InputIterator2 __last2,
2789 _OutputIterator __result)
2791 while (__first1 != __last1 && __first2 != __last2)
2793 if (*__first2 < *__first1)
2795 *__result = _GLIBCXX_MOVE(*__first2);
2800 *__result = _GLIBCXX_MOVE(*__first1);
2805 if (__first1 != __last1)
2806 _GLIBCXX_MOVE3(__first1, __last1, __result);
2810 template<
typename _InputIterator1,
typename _InputIterator2,
2811 typename _OutputIterator,
typename _Compare>
2814 _InputIterator2 __first2, _InputIterator2 __last2,
2815 _OutputIterator __result, _Compare __comp)
2817 while (__first1 != __last1 && __first2 != __last2)
2819 if (__comp(*__first2, *__first1))
2821 *__result = _GLIBCXX_MOVE(*__first2);
2826 *__result = _GLIBCXX_MOVE(*__first1);
2831 if (__first1 != __last1)
2832 _GLIBCXX_MOVE3(__first1, __last1, __result);
2836 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
2837 typename _BidirectionalIterator3>
2840 _BidirectionalIterator1 __last1,
2841 _BidirectionalIterator2 __first2,
2842 _BidirectionalIterator2 __last2,
2843 _BidirectionalIterator3 __result)
2845 if (__first1 == __last1)
2847 _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result);
2850 else if (__first2 == __last2)
2857 if (*__last2 < *__last1)
2859 *--__result = _GLIBCXX_MOVE(*__last1);
2860 if (__first1 == __last1)
2862 _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result);
2869 *--__result = _GLIBCXX_MOVE(*__last2);
2870 if (__first2 == __last2)
2878 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
2879 typename _BidirectionalIterator3,
typename _Compare>
2882 _BidirectionalIterator1 __last1,
2883 _BidirectionalIterator2 __first2,
2884 _BidirectionalIterator2 __last2,
2885 _BidirectionalIterator3 __result,
2888 if (__first1 == __last1)
2890 _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result);
2893 else if (__first2 == __last2)
2900 if (__comp(*__last2, *__last1))
2902 *--__result = _GLIBCXX_MOVE(*__last1);
2903 if (__first1 == __last1)
2905 _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result);
2912 *--__result = _GLIBCXX_MOVE(*__last2);
2913 if (__first2 == __last2)
2921 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
2923 _BidirectionalIterator1
2925 _BidirectionalIterator1 __middle,
2926 _BidirectionalIterator1 __last,
2927 _Distance __len1, _Distance __len2,
2928 _BidirectionalIterator2 __buffer,
2929 _Distance __buffer_size)
2931 _BidirectionalIterator2 __buffer_end;
2932 if (__len1 > __len2 && __len2 <= __buffer_size)
2936 __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
2937 _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last);
2938 return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first);
2943 else if (__len1 <= __buffer_size)
2947 __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
2948 _GLIBCXX_MOVE3(__middle, __last, __first);
2949 return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last);
2963 template<
typename _BidirectionalIterator,
typename _Distance,
2967 _BidirectionalIterator __middle,
2968 _BidirectionalIterator __last,
2969 _Distance __len1, _Distance __len2,
2970 _Pointer __buffer, _Distance __buffer_size)
2972 if (__len1 <= __len2 && __len1 <= __buffer_size)
2974 _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
2978 else if (__len2 <= __buffer_size)
2980 _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
2982 __buffer_end, __last);
2986 _BidirectionalIterator __first_cut = __first;
2987 _BidirectionalIterator __second_cut = __middle;
2988 _Distance __len11 = 0;
2989 _Distance __len22 = 0;
2990 if (__len1 > __len2)
2992 __len11 = __len1 / 2;
3000 __len22 = __len2 / 2;
3006 _BidirectionalIterator __new_middle =
3008 __len1 - __len11, __len22, __buffer,
3011 __len22, __buffer, __buffer_size);
3014 __len2 - __len22, __buffer, __buffer_size);
3019 template<
typename _BidirectionalIterator,
typename _Distance,
3020 typename _Pointer,
typename _Compare>
3023 _BidirectionalIterator __middle,
3024 _BidirectionalIterator __last,
3025 _Distance __len1, _Distance __len2,
3026 _Pointer __buffer, _Distance __buffer_size,
3029 if (__len1 <= __len2 && __len1 <= __buffer_size)
3031 _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
3035 else if (__len2 <= __buffer_size)
3037 _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
3039 __buffer_end, __last, __comp);
3043 _BidirectionalIterator __first_cut = __first;
3044 _BidirectionalIterator __second_cut = __middle;
3045 _Distance __len11 = 0;
3046 _Distance __len22 = 0;
3047 if (__len1 > __len2)
3049 __len11 = __len1 / 2;
3057 __len22 = __len2 / 2;
3063 _BidirectionalIterator __new_middle =
3065 __len1 - __len11, __len22, __buffer,
3068 __len22, __buffer, __buffer_size, __comp);
3071 __len2 - __len22, __buffer,
3072 __buffer_size, __comp);
3077 template<
typename _B
idirectionalIterator,
typename _Distance>
3080 _BidirectionalIterator __middle,
3081 _BidirectionalIterator __last,
3082 _Distance __len1, _Distance __len2)
3084 if (__len1 == 0 || __len2 == 0)
3086 if (__len1 + __len2 == 2)
3088 if (*__middle < *__first)
3092 _BidirectionalIterator __first_cut = __first;
3093 _BidirectionalIterator __second_cut = __middle;
3094 _Distance __len11 = 0;
3095 _Distance __len22 = 0;
3096 if (__len1 > __len2)
3098 __len11 = __len1 / 2;
3105 __len22 = __len2 / 2;
3111 _BidirectionalIterator __new_middle = __first_cut;
3116 __len1 - __len11, __len2 - __len22);
3120 template<
typename _BidirectionalIterator,
typename _Distance,
3124 _BidirectionalIterator __middle,
3125 _BidirectionalIterator __last,
3126 _Distance __len1, _Distance __len2,
3129 if (__len1 == 0 || __len2 == 0)
3131 if (__len1 + __len2 == 2)
3133 if (__comp(*__middle, *__first))
3137 _BidirectionalIterator __first_cut = __first;
3138 _BidirectionalIterator __second_cut = __middle;
3139 _Distance __len11 = 0;
3140 _Distance __len22 = 0;
3141 if (__len1 > __len2)
3143 __len11 = __len1 / 2;
3151 __len22 = __len2 / 2;
3158 _BidirectionalIterator __new_middle = __first_cut;
3161 __len11, __len22, __comp);
3163 __len1 - __len11, __len2 - __len22, __comp);
3184 template<
typename _B
idirectionalIterator>
3186 inplace_merge(_BidirectionalIterator __first,
3187 _BidirectionalIterator __middle,
3188 _BidirectionalIterator __last)
3190 typedef typename iterator_traits<_BidirectionalIterator>::value_type
3192 typedef typename iterator_traits<_BidirectionalIterator>::difference_type
3196 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
3197 _BidirectionalIterator>)
3198 __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
3199 __glibcxx_requires_sorted(__first, __middle);
3200 __glibcxx_requires_sorted(__middle, __last);
3202 if (__first == __middle || __middle == __last)
3210 if (__buf.
begin() == 0)
3214 __buf.
begin(), _DistanceType(__buf.
size()));
3239 template<
typename _B
idirectionalIterator,
typename _Compare>
3241 inplace_merge(_BidirectionalIterator __first,
3242 _BidirectionalIterator __middle,
3243 _BidirectionalIterator __last,
3246 typedef typename iterator_traits<_BidirectionalIterator>::value_type
3248 typedef typename iterator_traits<_BidirectionalIterator>::difference_type
3252 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
3253 _BidirectionalIterator>)
3254 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3255 _ValueType, _ValueType>)
3256 __glibcxx_requires_sorted_pred(__first, __middle, __comp);
3257 __glibcxx_requires_sorted_pred(__middle, __last, __comp);
3259 if (__first == __middle || __middle == __last)
3262 const _DistanceType __len1 =
std::distance(__first, __middle);
3263 const _DistanceType __len2 =
std::distance(__middle, __last);
3267 if (__buf.
begin() == 0)
3272 __buf.
begin(), _DistanceType(__buf.
size()),
3278 template<
typename _InputIterator1,
typename _InputIterator2,
3279 typename _OutputIterator>
3282 _InputIterator2 __first2, _InputIterator2 __last2,
3283 _OutputIterator __result)
3285 while (__first1 != __last1 && __first2 != __last2)
3287 if (*__first2 < *__first1)
3289 *__result = _GLIBCXX_MOVE(*__first2);
3294 *__result = _GLIBCXX_MOVE(*__first1);
3299 return _GLIBCXX_MOVE3(__first2, __last2,
3300 _GLIBCXX_MOVE3(__first1, __last1,
3305 template<
typename _InputIterator1,
typename _InputIterator2,
3306 typename _OutputIterator,
typename _Compare>
3309 _InputIterator2 __first2, _InputIterator2 __last2,
3310 _OutputIterator __result, _Compare __comp)
3312 while (__first1 != __last1 && __first2 != __last2)
3314 if (__comp(*__first2, *__first1))
3316 *__result = _GLIBCXX_MOVE(*__first2);
3321 *__result = _GLIBCXX_MOVE(*__first1);
3326 return _GLIBCXX_MOVE3(__first2, __last2,
3327 _GLIBCXX_MOVE3(__first1, __last1,
3331 template<
typename _RandomAccessIterator1,
typename _RandomAccessIterator2,
3334 __merge_sort_loop(_RandomAccessIterator1 __first,
3335 _RandomAccessIterator1 __last,
3336 _RandomAccessIterator2 __result,
3337 _Distance __step_size)
3339 const _Distance __two_step = 2 * __step_size;
3341 while (__last - __first >= __two_step)
3344 __first + __step_size,
3345 __first + __two_step, __result);
3346 __first += __two_step;
3349 __step_size =
std::min(_Distance(__last - __first), __step_size);
3351 __first + __step_size, __last, __result);
3354 template<
typename _RandomAccessIterator1,
typename _RandomAccessIterator2,
3355 typename _Distance,
typename _Compare>
3357 __merge_sort_loop(_RandomAccessIterator1 __first,
3358 _RandomAccessIterator1 __last,
3359 _RandomAccessIterator2 __result, _Distance __step_size,
3362 const _Distance __two_step = 2 * __step_size;
3364 while (__last - __first >= __two_step)
3367 __first + __step_size,
3368 __first + __two_step,
3370 __first += __two_step;
3372 __step_size =
std::min(_Distance(__last - __first), __step_size);
3375 __first + __step_size, __last, __result, __comp);
3378 template<
typename _RandomAccessIterator,
typename _Distance>
3380 __chunk_insertion_sort(_RandomAccessIterator __first,
3381 _RandomAccessIterator __last,
3382 _Distance __chunk_size)
3384 while (__last - __first >= __chunk_size)
3387 __first += __chunk_size;
3392 template<
typename _RandomAccessIterator,
typename _Distance,
3395 __chunk_insertion_sort(_RandomAccessIterator __first,
3396 _RandomAccessIterator __last,
3397 _Distance __chunk_size, _Compare __comp)
3399 while (__last - __first >= __chunk_size)
3402 __first += __chunk_size;
3407 enum { _S_chunk_size = 7 };
3409 template<
typename _RandomAccessIterator,
typename _Po
inter>
3411 __merge_sort_with_buffer(_RandomAccessIterator __first,
3412 _RandomAccessIterator __last,
3415 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
3418 const _Distance __len = __last - __first;
3419 const _Pointer __buffer_last = __buffer + __len;
3421 _Distance __step_size = _S_chunk_size;
3422 std::__chunk_insertion_sort(__first, __last, __step_size);
3424 while (__step_size < __len)
3426 std::__merge_sort_loop(__first, __last, __buffer, __step_size);
3428 std::__merge_sort_loop(__buffer, __buffer_last, __first, __step_size);
3433 template<
typename _RandomAccessIterator,
typename _Po
inter,
typename _Compare>
3435 __merge_sort_with_buffer(_RandomAccessIterator __first,
3436 _RandomAccessIterator __last,
3437 _Pointer __buffer, _Compare __comp)
3439 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
3442 const _Distance __len = __last - __first;
3443 const _Pointer __buffer_last = __buffer + __len;
3445 _Distance __step_size = _S_chunk_size;
3446 std::__chunk_insertion_sort(__first, __last, __step_size, __comp);
3448 while (__step_size < __len)
3450 std::__merge_sort_loop(__first, __last, __buffer,
3451 __step_size, __comp);
3453 std::__merge_sort_loop(__buffer, __buffer_last, __first,
3454 __step_size, __comp);
3459 template<
typename _RandomAccessIterator,
typename _Pointer,
3462 __stable_sort_adaptive(_RandomAccessIterator __first,
3463 _RandomAccessIterator __last,
3464 _Pointer __buffer, _Distance __buffer_size)
3466 const _Distance __len = (__last - __first + 1) / 2;
3467 const _RandomAccessIterator __middle = __first + __len;
3468 if (__len > __buffer_size)
3470 std::__stable_sort_adaptive(__first, __middle,
3471 __buffer, __buffer_size);
3472 std::__stable_sort_adaptive(__middle, __last,
3473 __buffer, __buffer_size);
3477 std::__merge_sort_with_buffer(__first, __middle, __buffer);
3478 std::__merge_sort_with_buffer(__middle, __last, __buffer);
3481 _Distance(__middle - __first),
3482 _Distance(__last - __middle),
3483 __buffer, __buffer_size);
3486 template<
typename _RandomAccessIterator,
typename _Pointer,
3487 typename _Distance,
typename _Compare>
3489 __stable_sort_adaptive(_RandomAccessIterator __first,
3490 _RandomAccessIterator __last,
3491 _Pointer __buffer, _Distance __buffer_size,
3494 const _Distance __len = (__last - __first + 1) / 2;
3495 const _RandomAccessIterator __middle = __first + __len;
3496 if (__len > __buffer_size)
3498 std::__stable_sort_adaptive(__first, __middle, __buffer,
3499 __buffer_size, __comp);
3500 std::__stable_sort_adaptive(__middle, __last, __buffer,
3501 __buffer_size, __comp);
3505 std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp);
3506 std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp);
3509 _Distance(__middle - __first),
3510 _Distance(__last - __middle),
3511 __buffer, __buffer_size,
3516 template<
typename _RandomAccessIterator>
3519 _RandomAccessIterator __last)
3521 if (__last - __first < 15)
3526 _RandomAccessIterator __middle = __first + (__last - __first) / 2;
3535 template<
typename _RandomAccessIterator,
typename _Compare>
3538 _RandomAccessIterator __last, _Compare __comp)
3540 if (__last - __first < 15)
3545 _RandomAccessIterator __middle = __first + (__last - __first) / 2;
3579 template<
typename _InputIterator1,
typename _InputIterator2>
3581 includes(_InputIterator1 __first1, _InputIterator1 __last1,
3582 _InputIterator2 __first2, _InputIterator2 __last2)
3584 typedef typename iterator_traits<_InputIterator1>::value_type
3586 typedef typename iterator_traits<_InputIterator2>::value_type
3590 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
3591 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
3592 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
3593 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
3594 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
3595 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
3597 while (__first1 != __last1 && __first2 != __last2)
3598 if (*__first2 < *__first1)
3600 else if(*__first1 < *__first2)
3603 ++__first1, ++__first2;
3605 return __first2 == __last2;
3629 template<
typename _InputIterator1,
typename _InputIterator2,
3632 includes(_InputIterator1 __first1, _InputIterator1 __last1,
3633 _InputIterator2 __first2, _InputIterator2 __last2,
3636 typedef typename iterator_traits<_InputIterator1>::value_type
3638 typedef typename iterator_traits<_InputIterator2>::value_type
3642 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
3643 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
3644 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3645 _ValueType1, _ValueType2>)
3646 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3647 _ValueType2, _ValueType1>)
3648 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
3649 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
3651 while (__first1 != __last1 && __first2 != __last2)
3652 if (__comp(*__first2, *__first1))
3654 else if(__comp(*__first1, *__first2))
3657 ++__first1, ++__first2;
3659 return __first2 == __last2;
3684 template<
typename _B
idirectionalIterator>
3686 next_permutation(_BidirectionalIterator __first,
3687 _BidirectionalIterator __last)
3690 __glibcxx_function_requires(_BidirectionalIteratorConcept<
3691 _BidirectionalIterator>)
3692 __glibcxx_function_requires(_LessThanComparableConcept<
3693 typename iterator_traits<_BidirectionalIterator>::value_type>)
3694 __glibcxx_requires_valid_range(__first, __last);
3696 if (__first == __last)
3698 _BidirectionalIterator __i = __first;
3707 _BidirectionalIterator __ii = __i;
3711 _BidirectionalIterator __j = __last;
3712 while (!(*__i < *--__j))
3741 template<
typename _B
idirectionalIterator,
typename _Compare>
3743 next_permutation(_BidirectionalIterator __first,
3744 _BidirectionalIterator __last, _Compare __comp)
3747 __glibcxx_function_requires(_BidirectionalIteratorConcept<
3748 _BidirectionalIterator>)
3749 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3750 typename iterator_traits<_BidirectionalIterator>::value_type,
3751 typename iterator_traits<_BidirectionalIterator>::value_type>)
3752 __glibcxx_requires_valid_range(__first, __last);
3754 if (__first == __last)
3756 _BidirectionalIterator __i = __first;
3765 _BidirectionalIterator __ii = __i;
3767 if (__comp(*__i, *__ii))
3769 _BidirectionalIterator __j = __last;
3770 while (!
bool(__comp(*__i, *--__j)))
3797 template<
typename _B
idirectionalIterator>
3799 prev_permutation(_BidirectionalIterator __first,
3800 _BidirectionalIterator __last)
3803 __glibcxx_function_requires(_BidirectionalIteratorConcept<
3804 _BidirectionalIterator>)
3805 __glibcxx_function_requires(_LessThanComparableConcept<
3806 typename iterator_traits<_BidirectionalIterator>::value_type>)
3807 __glibcxx_requires_valid_range(__first, __last);
3809 if (__first == __last)
3811 _BidirectionalIterator __i = __first;
3820 _BidirectionalIterator __ii = __i;
3824 _BidirectionalIterator __j = __last;
3825 while (!(*--__j < *__i))
3854 template<
typename _B
idirectionalIterator,
typename _Compare>
3856 prev_permutation(_BidirectionalIterator __first,
3857 _BidirectionalIterator __last, _Compare __comp)
3860 __glibcxx_function_requires(_BidirectionalIteratorConcept<
3861 _BidirectionalIterator>)
3862 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3863 typename iterator_traits<_BidirectionalIterator>::value_type,
3864 typename iterator_traits<_BidirectionalIterator>::value_type>)
3865 __glibcxx_requires_valid_range(__first, __last);
3867 if (__first == __last)
3869 _BidirectionalIterator __i = __first;
3878 _BidirectionalIterator __ii = __i;
3880 if (__comp(*__ii, *__i))
3882 _BidirectionalIterator __j = __last;
3883 while (!
bool(__comp(*--__j, *__i)))
3914 template<
typename _InputIterator,
typename _OutputIterator,
typename _Tp>
3916 replace_copy(_InputIterator __first, _InputIterator __last,
3917 _OutputIterator __result,
3918 const _Tp& __old_value,
const _Tp& __new_value)
3921 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3922 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
3923 typename iterator_traits<_InputIterator>::value_type>)
3924 __glibcxx_function_requires(_EqualOpConcept<
3925 typename iterator_traits<_InputIterator>::value_type, _Tp>)
3926 __glibcxx_requires_valid_range(__first, __last);
3928 for (; __first != __last; ++__first, ++__result)
3929 if (*__first == __old_value)
3930 *__result = __new_value;
3932 *__result = *__first;
3951 template<
typename _InputIterator,
typename _OutputIterator,
3952 typename _Predicate,
typename _Tp>
3954 replace_copy_if(_InputIterator __first, _InputIterator __last,
3955 _OutputIterator __result,
3956 _Predicate __pred,
const _Tp& __new_value)
3959 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3960 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
3961 typename iterator_traits<_InputIterator>::value_type>)
3962 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
3963 typename iterator_traits<_InputIterator>::value_type>)
3964 __glibcxx_requires_valid_range(__first, __last);
3966 for (; __first != __last; ++__first, ++__result)
3967 if (__pred(*__first))
3968 *__result = __new_value;
3970 *__result = *__first;
3974 #ifdef __GXX_EXPERIMENTAL_CXX0X__
3982 template<
typename _ForwardIterator>
3984 is_sorted(_ForwardIterator __first, _ForwardIterator __last)
3996 template<
typename _ForwardIterator,
typename _Compare>
3998 is_sorted(_ForwardIterator __first, _ForwardIterator __last,
4010 template<
typename _ForwardIterator>
4012 is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
4015 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4016 __glibcxx_function_requires(_LessThanComparableConcept<
4017 typename iterator_traits<_ForwardIterator>::value_type>)
4018 __glibcxx_requires_valid_range(__first, __last);
4020 if (__first == __last)
4023 _ForwardIterator __next = __first;
4024 for (++__next; __next != __last; __first = __next, ++__next)
4025 if (*__next < *__first)
4039 template<
typename _ForwardIterator,
typename _Compare>
4041 is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
4045 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4046 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
4047 typename iterator_traits<_ForwardIterator>::value_type,
4048 typename iterator_traits<_ForwardIterator>::value_type>)
4049 __glibcxx_requires_valid_range(__first, __last);
4051 if (__first == __last)
4054 _ForwardIterator __next = __first;
4055 for (++__next; __next != __last; __first = __next, ++__next)
4056 if (__comp(*__next, *__first))
4069 template<
typename _Tp>
4070 inline pair<const _Tp&, const _Tp&>
4074 __glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
4076 return __b < __a ? pair<const _Tp&, const _Tp&>(__b, __a)
4089 template<
typename _Tp,
typename _Compare>
4090 inline pair<const _Tp&, const _Tp&>
4091 minmax(
const _Tp& __a,
const _Tp& __b, _Compare __comp)
4108 template<
typename _ForwardIterator>
4109 pair<_ForwardIterator, _ForwardIterator>
4110 minmax_element(_ForwardIterator __first, _ForwardIterator __last)
4113 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4114 __glibcxx_function_requires(_LessThanComparableConcept<
4115 typename iterator_traits<_ForwardIterator>::value_type>)
4116 __glibcxx_requires_valid_range(__first, __last);
4118 _ForwardIterator __next = __first;
4119 if (__first == __last
4120 || ++__next == __last)
4123 _ForwardIterator __min, __max;
4124 if (*__next < *__first)
4138 while (__first != __last)
4141 if (++__next == __last)
4143 if (*__first < *__min)
4145 else if (!(*__first < *__max))
4150 if (*__next < *__first)
4152 if (*__next < *__min)
4154 if (!(*__first < *__max))
4159 if (*__first < *__min)
4161 if (!(*__next < *__max))
4184 template<
typename _ForwardIterator,
typename _Compare>
4185 pair<_ForwardIterator, _ForwardIterator>
4186 minmax_element(_ForwardIterator __first, _ForwardIterator __last,
4190 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4191 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
4192 typename iterator_traits<_ForwardIterator>::value_type,
4193 typename iterator_traits<_ForwardIterator>::value_type>)
4194 __glibcxx_requires_valid_range(__first, __last);
4196 _ForwardIterator __next = __first;
4197 if (__first == __last
4198 || ++__next == __last)
4201 _ForwardIterator __min, __max;
4202 if (__comp(*__next, *__first))
4216 while (__first != __last)
4219 if (++__next == __last)
4221 if (__comp(*__first, *__min))
4223 else if (!__comp(*__first, *__max))
4228 if (__comp(*__next, *__first))
4230 if (__comp(*__next, *__min))
4232 if (!__comp(*__first, *__max))
4237 if (__comp(*__first, *__min))
4239 if (!__comp(*__next, *__max))
4251 template<
typename _Tp>
4253 min(initializer_list<_Tp> __l)
4254 {
return *std::min_element(__l.begin(), __l.end()); }
4256 template<
typename _Tp,
typename _Compare>
4258 min(initializer_list<_Tp> __l, _Compare __comp)
4261 template<
typename _Tp>
4263 max(initializer_list<_Tp> __l)
4266 template<
typename _Tp,
typename _Compare>
4268 max(initializer_list<_Tp> __l, _Compare __comp)
4271 template<
typename _Tp>
4272 inline pair<_Tp, _Tp>
4273 minmax(initializer_list<_Tp> __l)
4275 pair<const _Tp*, const _Tp*> __p =
4280 template<
typename _Tp,
typename _Compare>
4281 inline pair<_Tp, _Tp>
4282 minmax(initializer_list<_Tp> __l, _Compare __comp)
4284 pair<const _Tp*, const _Tp*> __p =
4301 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
4303 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
4304 _ForwardIterator2 __first2)
4308 for (; __first1 != __last1; ++__first1, ++__first2)
4309 if (!(*__first1 == *__first2))
4312 if (__first1 == __last1)
4317 _ForwardIterator2 __last2 = __first2;
4319 for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
4324 auto __matches =
std::count(__first2, __last2, *__scan);
4326 ||
std::count(__scan, __last1, *__scan) != __matches)
4346 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
4347 typename _BinaryPredicate>
4349 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
4350 _ForwardIterator2 __first2, _BinaryPredicate __pred)
4354 for (; __first1 != __last1; ++__first1, ++__first2)
4355 if (!
bool(__pred(*__first1, *__first2)))
4358 if (__first1 == __last1)
4363 _ForwardIterator2 __last2 = __first2;
4365 for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
4367 using std::placeholders::_1;
4377 std::bind(__pred, _1, *__scan)) != __matches)
4383 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
4396 template<
typename _RandomAccessIterator,
4397 typename _UniformRandomNumberGenerator>
4399 shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
4400 _UniformRandomNumberGenerator&& __g)
4403 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4404 _RandomAccessIterator>)
4405 __glibcxx_requires_valid_range(__first, __last);
4407 if (__first == __last)
4410 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
4413 typedef typename std::make_unsigned<_DistanceType>::type __ud_type;
4415 typedef typename __distr_type::param_type __p_type;
4418 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
4419 std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first)));
4423 #endif // __GXX_EXPERIMENTAL_CXX0X__
4425 _GLIBCXX_END_NAMESPACE_VERSION
4427 _GLIBCXX_BEGIN_NAMESPACE_ALGO
4441 template<
typename _InputIterator,
typename _Function>
4443 for_each(_InputIterator __first, _InputIterator __last, _Function __f)
4446 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4447 __glibcxx_requires_valid_range(__first, __last);
4448 for (; __first != __last; ++__first)
4450 return _GLIBCXX_MOVE(__f);
4462 template<
typename _InputIterator,
typename _Tp>
4463 inline _InputIterator
4464 find(_InputIterator __first, _InputIterator __last,
4468 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4469 __glibcxx_function_requires(_EqualOpConcept<
4470 typename iterator_traits<_InputIterator>::value_type, _Tp>)
4471 __glibcxx_requires_valid_range(__first, __last);
4486 template<
typename _InputIterator,
typename _Predicate>
4487 inline _InputIterator
4488 find_if(_InputIterator __first, _InputIterator __last,
4492 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4493 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
4494 typename iterator_traits<_InputIterator>::value_type>)
4495 __glibcxx_requires_valid_range(__first, __last);
4516 template<
typename _InputIterator,
typename _ForwardIterator>
4518 find_first_of(_InputIterator __first1, _InputIterator __last1,
4519 _ForwardIterator __first2, _ForwardIterator __last2)
4522 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4523 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4524 __glibcxx_function_requires(_EqualOpConcept<
4525 typename iterator_traits<_InputIterator>::value_type,
4526 typename iterator_traits<_ForwardIterator>::value_type>)
4527 __glibcxx_requires_valid_range(__first1, __last1);
4528 __glibcxx_requires_valid_range(__first2, __last2);
4530 for (; __first1 != __last1; ++__first1)
4531 for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
4532 if (*__first1 == *__iter)
4556 template<
typename _InputIterator,
typename _ForwardIterator,
4557 typename _BinaryPredicate>
4559 find_first_of(_InputIterator __first1, _InputIterator __last1,
4560 _ForwardIterator __first2, _ForwardIterator __last2,
4561 _BinaryPredicate __comp)
4564 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4565 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4566 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4567 typename iterator_traits<_InputIterator>::value_type,
4568 typename iterator_traits<_ForwardIterator>::value_type>)
4569 __glibcxx_requires_valid_range(__first1, __last1);
4570 __glibcxx_requires_valid_range(__first2, __last2);
4572 for (; __first1 != __last1; ++__first1)
4573 for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
4574 if (__comp(*__first1, *__iter))
4588 template<
typename _ForwardIterator>
4590 adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
4593 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4594 __glibcxx_function_requires(_EqualityComparableConcept<
4595 typename iterator_traits<_ForwardIterator>::value_type>)
4596 __glibcxx_requires_valid_range(__first, __last);
4597 if (__first == __last)
4599 _ForwardIterator __next = __first;
4600 while(++__next != __last)
4602 if (*__first == *__next)
4620 template<
typename _ForwardIterator,
typename _BinaryPredicate>
4622 adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
4623 _BinaryPredicate __binary_pred)
4626 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4627 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4628 typename iterator_traits<_ForwardIterator>::value_type,
4629 typename iterator_traits<_ForwardIterator>::value_type>)
4630 __glibcxx_requires_valid_range(__first, __last);
4631 if (__first == __last)
4633 _ForwardIterator __next = __first;
4634 while(++__next != __last)
4636 if (__binary_pred(*__first, *__next))
4652 template<
typename _InputIterator,
typename _Tp>
4653 typename iterator_traits<_InputIterator>::difference_type
4654 count(_InputIterator __first, _InputIterator __last,
const _Tp& __value)
4657 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4658 __glibcxx_function_requires(_EqualOpConcept<
4659 typename iterator_traits<_InputIterator>::value_type, _Tp>)
4660 __glibcxx_requires_valid_range(__first, __last);
4661 typename iterator_traits<_InputIterator>::difference_type __n = 0;
4662 for (; __first != __last; ++__first)
4663 if (*__first == __value)
4677 template<
typename _InputIterator,
typename _Predicate>
4678 typename iterator_traits<_InputIterator>::difference_type
4679 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
4682 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4683 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
4684 typename iterator_traits<_InputIterator>::value_type>)
4685 __glibcxx_requires_valid_range(__first, __last);
4686 typename iterator_traits<_InputIterator>::difference_type __n = 0;
4687 for (; __first != __last; ++__first)
4688 if (__pred(*__first))
4719 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
4721 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
4722 _ForwardIterator2 __first2, _ForwardIterator2 __last2)
4725 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
4726 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
4727 __glibcxx_function_requires(_EqualOpConcept<
4728 typename iterator_traits<_ForwardIterator1>::value_type,
4729 typename iterator_traits<_ForwardIterator2>::value_type>)
4730 __glibcxx_requires_valid_range(__first1, __last1);
4731 __glibcxx_requires_valid_range(__first2, __last2);
4734 if (__first1 == __last1 || __first2 == __last2)
4738 _ForwardIterator2 __p1(__first2);
4739 if (++__p1 == __last2)
4743 _ForwardIterator2 __p;
4744 _ForwardIterator1 __current = __first1;
4749 if (__first1 == __last1)
4753 __current = __first1;
4754 if (++__current == __last1)
4757 while (*__current == *__p)
4759 if (++__p == __last2)
4761 if (++__current == __last1)
4790 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
4791 typename _BinaryPredicate>
4793 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
4794 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
4795 _BinaryPredicate __predicate)
4798 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
4799 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
4800 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4801 typename iterator_traits<_ForwardIterator1>::value_type,
4802 typename iterator_traits<_ForwardIterator2>::value_type>)
4803 __glibcxx_requires_valid_range(__first1, __last1);
4804 __glibcxx_requires_valid_range(__first2, __last2);
4807 if (__first1 == __last1 || __first2 == __last2)
4811 _ForwardIterator2 __p1(__first2);
4812 if (++__p1 == __last2)
4814 while (__first1 != __last1
4815 && !
bool(__predicate(*__first1, *__first2)))
4821 _ForwardIterator2 __p;
4822 _ForwardIterator1 __current = __first1;
4826 while (__first1 != __last1
4827 && !
bool(__predicate(*__first1, *__first2)))
4829 if (__first1 == __last1)
4833 __current = __first1;
4834 if (++__current == __last1)
4837 while (__predicate(*__current, *__p))
4839 if (++__p == __last2)
4841 if (++__current == __last1)
4865 template<
typename _ForwardIterator,
typename _Integer,
typename _Tp>
4867 search_n(_ForwardIterator __first, _ForwardIterator __last,
4868 _Integer __count,
const _Tp& __val)
4871 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4872 __glibcxx_function_requires(_EqualOpConcept<
4873 typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
4874 __glibcxx_requires_valid_range(__first, __last);
4902 template<
typename _ForwardIterator,
typename _Integer,
typename _Tp,
4903 typename _BinaryPredicate>
4905 search_n(_ForwardIterator __first, _ForwardIterator __last,
4906 _Integer __count,
const _Tp& __val,
4907 _BinaryPredicate __binary_pred)
4910 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4911 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4912 typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
4913 __glibcxx_requires_valid_range(__first, __last);
4919 while (__first != __last && !
bool(__binary_pred(*__first, __val)))
4923 return std::__search_n(__first, __last, __count, __val, __binary_pred,
4944 template<
typename _InputIterator,
typename _OutputIterator,
4945 typename _UnaryOperation>
4947 transform(_InputIterator __first, _InputIterator __last,
4948 _OutputIterator __result, _UnaryOperation __unary_op)
4951 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4952 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4954 __typeof__(__unary_op(*__first))>)
4955 __glibcxx_requires_valid_range(__first, __last);
4957 for (; __first != __last; ++__first, ++__result)
4958 *__result = __unary_op(*__first);
4981 template<
typename _InputIterator1,
typename _InputIterator2,
4982 typename _OutputIterator,
typename _BinaryOperation>
4984 transform(_InputIterator1 __first1, _InputIterator1 __last1,
4985 _InputIterator2 __first2, _OutputIterator __result,
4986 _BinaryOperation __binary_op)
4989 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
4990 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
4991 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4993 __typeof__(__binary_op(*__first1,*__first2))>)
4994 __glibcxx_requires_valid_range(__first1, __last1);
4996 for (; __first1 != __last1; ++__first1, ++__first2, ++__result)
4997 *__result = __binary_op(*__first1, *__first2);
5014 template<
typename _ForwardIterator,
typename _Tp>
5016 replace(_ForwardIterator __first, _ForwardIterator __last,
5017 const _Tp& __old_value,
const _Tp& __new_value)
5020 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
5022 __glibcxx_function_requires(_EqualOpConcept<
5023 typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
5024 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
5025 typename iterator_traits<_ForwardIterator>::value_type>)
5026 __glibcxx_requires_valid_range(__first, __last);
5028 for (; __first != __last; ++__first)
5029 if (*__first == __old_value)
5030 *__first = __new_value;
5046 template<
typename _ForwardIterator,
typename _Predicate,
typename _Tp>
5048 replace_if(_ForwardIterator __first, _ForwardIterator __last,
5049 _Predicate __pred,
const _Tp& __new_value)
5052 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
5054 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
5055 typename iterator_traits<_ForwardIterator>::value_type>)
5056 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
5057 typename iterator_traits<_ForwardIterator>::value_type>)
5058 __glibcxx_requires_valid_range(__first, __last);
5060 for (; __first != __last; ++__first)
5061 if (__pred(*__first))
5062 *__first = __new_value;
5078 template<
typename _ForwardIterator,
typename _Generator>
5080 generate(_ForwardIterator __first, _ForwardIterator __last,
5084 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
5085 __glibcxx_function_requires(_GeneratorConcept<_Generator,
5086 typename iterator_traits<_ForwardIterator>::value_type>)
5087 __glibcxx_requires_valid_range(__first, __last);
5089 for (; __first != __last; ++__first)
5109 template<
typename _OutputIterator,
typename _Size,
typename _Generator>
5111 generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
5114 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5116 __typeof__(__gen())>)
5118 for (__decltype(__n + 0) __niter = __n;
5119 __niter > 0; --__niter, ++__first)
5146 template<
typename _InputIterator,
typename _OutputIterator>
5147 inline _OutputIterator
5148 unique_copy(_InputIterator __first, _InputIterator __last,
5149 _OutputIterator __result)
5152 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
5153 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5154 typename iterator_traits<_InputIterator>::value_type>)
5155 __glibcxx_function_requires(_EqualityComparableConcept<
5156 typename iterator_traits<_InputIterator>::value_type>)
5157 __glibcxx_requires_valid_range(__first, __last);
5159 if (__first == __last)
5185 template<
typename _InputIterator,
typename _OutputIterator,
5186 typename _BinaryPredicate>
5187 inline _OutputIterator
5188 unique_copy(_InputIterator __first, _InputIterator __last,
5189 _OutputIterator __result,
5190 _BinaryPredicate __binary_pred)
5193 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
5194 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5195 typename iterator_traits<_InputIterator>::value_type>)
5196 __glibcxx_requires_valid_range(__first, __last);
5198 if (__first == __last)
5217 template<
typename _RandomAccessIterator>
5219 random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
5222 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5223 _RandomAccessIterator>)
5224 __glibcxx_requires_valid_range(__first, __last);
5226 if (__first != __last)
5227 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
5228 std::iter_swap(__i, __first + (std::rand() % ((__i - __first) + 1)));
5245 template<
typename _RandomAccessIterator,
typename _RandomNumberGenerator>
5247 random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
5248 #ifdef __GXX_EXPERIMENTAL_CXX0X__
5249 _RandomNumberGenerator&& __rand)
5251 _RandomNumberGenerator& __rand)
5255 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5256 _RandomAccessIterator>)
5257 __glibcxx_requires_valid_range(__first, __last);
5259 if (__first == __last)
5261 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
5281 template<
typename _ForwardIterator,
typename _Predicate>
5282 inline _ForwardIterator
5283 partition(_ForwardIterator __first, _ForwardIterator __last,
5287 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
5289 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
5290 typename iterator_traits<_ForwardIterator>::value_type>)
5291 __glibcxx_requires_valid_range(__first, __last);
5315 template<
typename _RandomAccessIterator>
5317 partial_sort(_RandomAccessIterator __first,
5318 _RandomAccessIterator __middle,
5319 _RandomAccessIterator __last)
5321 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5325 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5326 _RandomAccessIterator>)
5327 __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
5328 __glibcxx_requires_valid_range(__first, __middle);
5329 __glibcxx_requires_valid_range(__middle, __last);
5354 template<
typename _RandomAccessIterator,
typename _Compare>
5356 partial_sort(_RandomAccessIterator __first,
5357 _RandomAccessIterator __middle,
5358 _RandomAccessIterator __last,
5361 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5365 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5366 _RandomAccessIterator>)
5367 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5368 _ValueType, _ValueType>)
5369 __glibcxx_requires_valid_range(__first, __middle);
5370 __glibcxx_requires_valid_range(__middle, __last);
5391 template<
typename _RandomAccessIterator>
5393 nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
5394 _RandomAccessIterator __last)
5396 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5400 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5401 _RandomAccessIterator>)
5402 __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
5403 __glibcxx_requires_valid_range(__first, __nth);
5404 __glibcxx_requires_valid_range(__nth, __last);
5406 if (__first == __last || __nth == __last)
5409 std::__introselect(__first, __nth, __last,
5430 template<
typename _RandomAccessIterator,
typename _Compare>
5432 nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
5433 _RandomAccessIterator __last, _Compare __comp)
5435 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5439 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5440 _RandomAccessIterator>)
5441 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5442 _ValueType, _ValueType>)
5443 __glibcxx_requires_valid_range(__first, __nth);
5444 __glibcxx_requires_valid_range(__nth, __last);
5446 if (__first == __last || __nth == __last)
5449 std::__introselect(__first, __nth, __last,
5450 std::__lg(__last - __first) * 2, __comp);
5468 template<
typename _RandomAccessIterator>
5470 sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
5472 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5476 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5477 _RandomAccessIterator>)
5478 __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
5479 __glibcxx_requires_valid_range(__first, __last);
5481 if (__first != __last)
5504 template<
typename _RandomAccessIterator,
typename _Compare>
5506 sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
5509 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5513 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5514 _RandomAccessIterator>)
5515 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, _ValueType,
5517 __glibcxx_requires_valid_range(__first, __last);
5519 if (__first != __last)
5522 std::__lg(__last - __first) * 2, __comp);
5546 template<
typename _InputIterator1,
typename _InputIterator2,
5547 typename _OutputIterator>
5549 merge(_InputIterator1 __first1, _InputIterator1 __last1,
5550 _InputIterator2 __first2, _InputIterator2 __last2,
5551 _OutputIterator __result)
5553 typedef typename iterator_traits<_InputIterator1>::value_type
5555 typedef typename iterator_traits<_InputIterator2>::value_type
5559 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5560 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5561 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5563 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5565 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
5566 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5567 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5569 while (__first1 != __last1 && __first2 != __last2)
5571 if (*__first2 < *__first1)
5573 *__result = *__first2;
5578 *__result = *__first1;
5583 return std::copy(__first2, __last2, std::copy(__first1, __last1,
5610 template<
typename _InputIterator1,
typename _InputIterator2,
5611 typename _OutputIterator,
typename _Compare>
5613 merge(_InputIterator1 __first1, _InputIterator1 __last1,
5614 _InputIterator2 __first2, _InputIterator2 __last2,
5615 _OutputIterator __result, _Compare __comp)
5617 typedef typename iterator_traits<_InputIterator1>::value_type
5619 typedef typename iterator_traits<_InputIterator2>::value_type
5623 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5624 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5625 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5627 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5629 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5630 _ValueType2, _ValueType1>)
5631 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5632 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5634 while (__first1 != __last1 && __first2 != __last2)
5636 if (__comp(*__first2, *__first1))
5638 *__result = *__first2;
5643 *__result = *__first1;
5648 return std::copy(__first2, __last2, std::copy(__first1, __last1,
5670 template<
typename _RandomAccessIterator>
5672 stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
5674 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5676 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
5680 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5681 _RandomAccessIterator>)
5682 __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
5683 __glibcxx_requires_valid_range(__first, __last);
5687 if (__buf.
begin() == 0)
5690 std::__stable_sort_adaptive(__first, __last, __buf.
begin(),
5691 _DistanceType(__buf.
size()));
5712 template<
typename _RandomAccessIterator,
typename _Compare>
5714 stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
5717 typedef typename iterator_traits<_RandomAccessIterator>::value_type
5719 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
5723 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5724 _RandomAccessIterator>)
5725 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5728 __glibcxx_requires_valid_range(__first, __last);
5732 if (__buf.
begin() == 0)
5735 std::__stable_sort_adaptive(__first, __last, __buf.
begin(),
5736 _DistanceType(__buf.
size()), __comp);
5758 template<
typename _InputIterator1,
typename _InputIterator2,
5759 typename _OutputIterator>
5761 set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5762 _InputIterator2 __first2, _InputIterator2 __last2,
5763 _OutputIterator __result)
5765 typedef typename iterator_traits<_InputIterator1>::value_type
5767 typedef typename iterator_traits<_InputIterator2>::value_type
5771 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5772 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5773 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5775 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5777 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
5778 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
5779 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5780 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5782 while (__first1 != __last1 && __first2 != __last2)
5784 if (*__first1 < *__first2)
5786 *__result = *__first1;
5789 else if (*__first2 < *__first1)
5791 *__result = *__first2;
5796 *__result = *__first1;
5802 return std::copy(__first2, __last2, std::copy(__first1, __last1,
5825 template<
typename _InputIterator1,
typename _InputIterator2,
5826 typename _OutputIterator,
typename _Compare>
5828 set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5829 _InputIterator2 __first2, _InputIterator2 __last2,
5830 _OutputIterator __result, _Compare __comp)
5832 typedef typename iterator_traits<_InputIterator1>::value_type
5834 typedef typename iterator_traits<_InputIterator2>::value_type
5838 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5839 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5840 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5842 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5844 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5845 _ValueType1, _ValueType2>)
5846 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5847 _ValueType2, _ValueType1>)
5848 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5849 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5851 while (__first1 != __last1 && __first2 != __last2)
5853 if (__comp(*__first1, *__first2))
5855 *__result = *__first1;
5858 else if (__comp(*__first2, *__first1))
5860 *__result = *__first2;
5865 *__result = *__first1;
5871 return std::copy(__first2, __last2, std::copy(__first1, __last1,
5892 template<
typename _InputIterator1,
typename _InputIterator2,
5893 typename _OutputIterator>
5895 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5896 _InputIterator2 __first2, _InputIterator2 __last2,
5897 _OutputIterator __result)
5899 typedef typename iterator_traits<_InputIterator1>::value_type
5901 typedef typename iterator_traits<_InputIterator2>::value_type
5905 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5906 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5907 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5909 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
5910 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
5911 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5912 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5914 while (__first1 != __last1 && __first2 != __last2)
5915 if (*__first1 < *__first2)
5917 else if (*__first2 < *__first1)
5921 *__result = *__first1;
5949 template<
typename _InputIterator1,
typename _InputIterator2,
5950 typename _OutputIterator,
typename _Compare>
5952 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5953 _InputIterator2 __first2, _InputIterator2 __last2,
5954 _OutputIterator __result, _Compare __comp)
5956 typedef typename iterator_traits<_InputIterator1>::value_type
5958 typedef typename iterator_traits<_InputIterator2>::value_type
5962 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5963 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5964 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5966 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5967 _ValueType1, _ValueType2>)
5968 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5969 _ValueType2, _ValueType1>)
5970 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5971 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5973 while (__first1 != __last1 && __first2 != __last2)
5974 if (__comp(*__first1, *__first2))
5976 else if (__comp(*__first2, *__first1))
5980 *__result = *__first1;
6007 template<
typename _InputIterator1,
typename _InputIterator2,
6008 typename _OutputIterator>
6010 set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
6011 _InputIterator2 __first2, _InputIterator2 __last2,
6012 _OutputIterator __result)
6014 typedef typename iterator_traits<_InputIterator1>::value_type
6016 typedef typename iterator_traits<_InputIterator2>::value_type
6020 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
6021 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
6022 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
6024 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
6025 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
6026 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
6027 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
6029 while (__first1 != __last1 && __first2 != __last2)
6030 if (*__first1 < *__first2)
6032 *__result = *__first1;
6036 else if (*__first2 < *__first1)
6043 return std::copy(__first1, __last1, __result);
6068 template<
typename _InputIterator1,
typename _InputIterator2,
6069 typename _OutputIterator,
typename _Compare>
6071 set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
6072 _InputIterator2 __first2, _InputIterator2 __last2,
6073 _OutputIterator __result, _Compare __comp)
6075 typedef typename iterator_traits<_InputIterator1>::value_type
6077 typedef typename iterator_traits<_InputIterator2>::value_type
6081 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
6082 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
6083 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
6085 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
6086 _ValueType1, _ValueType2>)
6087 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
6088 _ValueType2, _ValueType1>)
6089 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
6090 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
6092 while (__first1 != __last1 && __first2 != __last2)
6093 if (__comp(*__first1, *__first2))
6095 *__result = *__first1;
6099 else if (__comp(*__first2, *__first1))
6106 return std::copy(__first1, __last1, __result);
6126 template<
typename _InputIterator1,
typename _InputIterator2,
6127 typename _OutputIterator>
6129 set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
6130 _InputIterator2 __first2, _InputIterator2 __last2,
6131 _OutputIterator __result)
6133 typedef typename iterator_traits<_InputIterator1>::value_type
6135 typedef typename iterator_traits<_InputIterator2>::value_type
6139 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
6140 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
6141 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
6143 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
6145 __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>)
6146 __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>)
6147 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
6148 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
6150 while (__first1 != __last1 && __first2 != __last2)
6151 if (*__first1 < *__first2)
6153 *__result = *__first1;
6157 else if (*__first2 < *__first1)
6159 *__result = *__first2;
6168 return std::copy(__first2, __last2, std::copy(__first1,
6169 __last1, __result));
6192 template<
typename _InputIterator1,
typename _InputIterator2,
6193 typename _OutputIterator,
typename _Compare>
6195 set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
6196 _InputIterator2 __first2, _InputIterator2 __last2,
6197 _OutputIterator __result,
6200 typedef typename iterator_traits<_InputIterator1>::value_type
6202 typedef typename iterator_traits<_InputIterator2>::value_type
6206 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
6207 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
6208 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
6210 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
6212 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
6213 _ValueType1, _ValueType2>)
6214 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
6215 _ValueType2, _ValueType1>)
6216 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
6217 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
6219 while (__first1 != __last1 && __first2 != __last2)
6220 if (__comp(*__first1, *__first2))
6222 *__result = *__first1;
6226 else if (__comp(*__first2, *__first1))
6228 *__result = *__first2;
6237 return std::copy(__first2, __last2,
6238 std::copy(__first1, __last1, __result));
6249 template<
typename _ForwardIterator>
6251 min_element(_ForwardIterator __first, _ForwardIterator __last)
6254 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
6255 __glibcxx_function_requires(_LessThanComparableConcept<
6256 typename iterator_traits<_ForwardIterator>::value_type>)
6257 __glibcxx_requires_valid_range(__first, __last);
6259 if (__first == __last)
6261 _ForwardIterator __result = __first;
6262 while (++__first != __last)
6263 if (*__first < *__result)
6277 template<
typename _ForwardIterator,
typename _Compare>
6279 min_element(_ForwardIterator __first, _ForwardIterator __last,
6283 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
6284 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
6285 typename iterator_traits<_ForwardIterator>::value_type,
6286 typename iterator_traits<_ForwardIterator>::value_type>)
6287 __glibcxx_requires_valid_range(__first, __last);
6289 if (__first == __last)
6291 _ForwardIterator __result = __first;
6292 while (++__first != __last)
6293 if (__comp(*__first, *__result))
6305 template<
typename _ForwardIterator>
6307 max_element(_ForwardIterator __first, _ForwardIterator __last)
6310 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
6311 __glibcxx_function_requires(_LessThanComparableConcept<
6312 typename iterator_traits<_ForwardIterator>::value_type>)
6313 __glibcxx_requires_valid_range(__first, __last);
6315 if (__first == __last)
6317 _ForwardIterator __result = __first;
6318 while (++__first != __last)
6319 if (*__result < *__first)
6333 template<
typename _ForwardIterator,
typename _Compare>
6335 max_element(_ForwardIterator __first, _ForwardIterator __last,
6339 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
6340 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
6341 typename iterator_traits<_ForwardIterator>::value_type,
6342 typename iterator_traits<_ForwardIterator>::value_type>)
6343 __glibcxx_requires_valid_range(__first, __last);
6345 if (__first == __last)
return __first;
6346 _ForwardIterator __result = __first;
6347 while (++__first != __last)
6348 if (__comp(*__result, *__first))
6353 _GLIBCXX_END_NAMESPACE_ALGO
iterator begin()
As per Table mumble.
_RandomAccessIterator __unguarded_partition_pivot(_RandomAccessIterator __first, _RandomAccessIterator __last)
This is a helper function...
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Construct a heap over a range using comparison functor.
_ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
Return the maximum element in a range using comparison functor.
_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __predicate)
Search a sequence for a matching sub-sequence using a predicate.
Bidirectional iterators support a superset of forward iterator operations.
void __introsort_loop(_RandomAccessIterator __first, _RandomAccessIterator __last, _Size __depth_limit)
This is a helper function for the sort routine.
size_type requested_size() const
Returns the size requested by the constructor; may be >size().
void __merge_without_buffer(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2)
This is a helper function for the merge routines.
void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
Swaps the contents of two iterators.
_ForwardIterator __inplace_stable_partition(_ForwardIterator __first, _Predicate __pred, _Distance __len)
This is a helper function... Requires __len != 0 and !__pred(*__first), same as __stable_partition_ad...
pair< const _Tp &, const _Tp & > minmax(const _Tp &, const _Tp &)
Determines min and max at once as an ordered pair.
_ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
Determines the end of a sorted sequence using comparison functor.
void __final_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
This is a helper function for the sort routine.
void __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, forward_iterator_tag)
This is a helper function for the rotate algorithm.
void __merge_adaptive(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Pointer __buffer, _Distance __buffer_size)
This is a helper function for the merge routines.
_ForwardIterator2 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
Swap the elements of two sequences.
_EuclideanRingElement __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
void __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
This is a helper function for the __merge_adaptive routines.
_ForwardIterator __stable_partition_adaptive(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, _Distance __len, _Pointer __buffer, _Distance __buffer_size)
This is a helper function... Requires __first != __last and !__pred(*__first) and __len == distance(_...
void rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
Rotate the elements of a sequence.
_Size __lg(_Size __n)
This is a helper function for the sort routines and for random.tcc.
iterator_traits< _InputIterator >::difference_type count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
Count the elements of a sequence for which a predicate is true.
pair< _ForwardIterator, _ForwardIterator > minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
Return a pair of iterators pointing to the minimum and maximum elements in a range.
Marking output iterators.
_InputIterator __find_if_not_n(_InputIterator __first, _Distance &__len, _Predicate __pred)
Like find_if_not(), but uses and updates a count of the remaining range length instead of comparing a...
_Bind_helper< __is_socketlike< _Func >::value, _Func, _BoundArgs...>::type bind(_Func &&__f, _BoundArgs &&...__args)
Function template for std::bind.
size_t count() const _GLIBCXX_NOEXCEPT
Returns the number of bits which are set.
bool none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
Checks that a predicate is false for all the elements of a sequence.
void __move_median_to_first(_Iterator __result, _Iterator __a, _Iterator __b, _Iterator __c)
Swaps the median value of *__a, *__b and *__c to *__result.
_OutputIterator __move_merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
This is a helper function for the __merge_sort_loop routines.
void __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BidirectionalIterator3 __result)
This is a helper function for the __merge_adaptive routines.
_BidirectionalIterator1 __rotate_adaptive(_BidirectionalIterator1 __first, _BidirectionalIterator1 __middle, _BidirectionalIterator1 __last, _Distance __len1, _Distance __len2, _BidirectionalIterator2 __buffer, _Distance __buffer_size)
This is a helper function for the merge routines.
_InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp &__val)
Find the first occurrence of a value in a sequence.
_ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
Return the minimum element in a range using comparison functor.
const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
void __unguarded_linear_insert(_RandomAccessIterator __last)
This is a helper function for the sort routine.
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
_InputIterator find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
Find the first element in a sequence for which a predicate is true.
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Sort a heap using comparison functor.
size_type size() const
As per Table mumble.
void __heap_select(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
This is a helper function for the sort routines.
_InputIterator __find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag)
This is an overload used by find_if_not() for the Input Iterator case.
_RandomAccessIterator __unguarded_partition(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp &__pivot)
This is a helper function...
_ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp &__val, std::forward_iterator_tag)
Struct holding two objects of arbitrary type.
_ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val, _Compare __comp)
Finds the last position in which __val could be inserted without changing the ordering.
void reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
Reverse a sequence.
Uniform discrete distribution for random numbers. A discrete random distribution on the range with e...
_InputIterator __find(_InputIterator __first, _InputIterator __last, const _Tp &__val, input_iterator_tag)
This is an overload used by find() for the Input Iterator case.
_InputIterator find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
Find the first element in a sequence for which a predicate is false.
_InputIterator __find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag)
This is an overload used by find_if() for the Input Iterator case.
Forward iterators support a superset of input iterator operations.
void __unguarded_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
This is a helper function for the sort routine.
_ForwardIterator __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
This is a helper function...
_OutputIterator __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, forward_iterator_tag, output_iterator_tag)
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
void __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
Random-access iterators support a superset of bidirectional iterator operations.
_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)
Finds the first position in which val could be inserted without changing the ordering.
void __insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
This is a helper function for the sort routine.
void __inplace_stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
This is a helper function for the stable sorting routines.
void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp)
Sort the smallest elements of a sequence using a predicate for comparison.
_ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred)
Find two adjacent values in a sequence using a predicate.