64#if __cplusplus >= 201103L
68#if _GLIBCXX_HOSTED && (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED)
74namespace std _GLIBCXX_VISIBILITY(default)
76_GLIBCXX_BEGIN_NAMESPACE_VERSION
79 template<
typename _Iterator,
typename _Compare>
83 _Iterator __c, _Compare __comp)
88 std::iter_swap(__result, __b);
89 else if (__comp(__a, __c))
90 std::iter_swap(__result, __c);
92 std::iter_swap(__result, __a);
94 else if (__comp(__a, __c))
95 std::iter_swap(__result, __a);
96 else if (__comp(__b, __c))
97 std::iter_swap(__result, __c);
99 std::iter_swap(__result, __b);
103 template<
typename _InputIterator,
typename _Predicate>
105 inline _InputIterator
110 __gnu_cxx::__ops::__negate(__pred),
117 template<
typename _InputIterator,
typename _Predicate,
typename _Distance>
122 for (; __len; --__len, (void) ++__first)
123 if (!__pred(__first))
141 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
142 typename _BinaryPredicate>
145 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
146 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
147 _BinaryPredicate __predicate)
150 if (__first1 == __last1 || __first2 == __last2)
154 _ForwardIterator2 __p1(__first2);
155 if (++__p1 == __last2)
157 __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
160 _ForwardIterator1 __current = __first1;
166 __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
168 if (__first1 == __last1)
171 _ForwardIterator2 __p = __p1;
172 __current = __first1;
173 if (++__current == __last1)
176 while (__predicate(__current, __p))
178 if (++__p == __last2)
180 if (++__current == __last1)
193 template<
typename _ForwardIterator,
typename _Integer,
194 typename _UnaryPredicate>
198 _Integer __count, _UnaryPredicate __unary_pred,
202 while (__first != __last)
206 _ForwardIterator __i = __first;
208 while (__i != __last && __n != 1 && __unary_pred(__i))
226 template<
typename _RandomAccessIter,
typename _Integer,
227 typename _UnaryPredicate>
231 _Integer __count, _UnaryPredicate __unary_pred,
237 _DistanceType __tailSize = __last - __first;
238 _DistanceType __remainder = __count;
240 while (__remainder <= __tailSize)
242 __first += __remainder;
243 __tailSize -= __remainder;
246 _RandomAccessIter __backTrack = __first;
247 while (__unary_pred(--__backTrack))
249 if (--__remainder == 0)
250 return (__first - __count);
252 __remainder = __count + 1 - (__first - __backTrack);
257 template<
typename _ForwardIterator,
typename _Integer,
258 typename _UnaryPredicate>
261 __search_n(_ForwardIterator __first, _ForwardIterator __last,
263 _UnaryPredicate __unary_pred)
276 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
277 typename _BinaryPredicate>
280 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
281 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
282 forward_iterator_tag, forward_iterator_tag,
283 _BinaryPredicate __comp)
285 if (__first2 == __last2)
288 _ForwardIterator1 __result = __last1;
291 _ForwardIterator1 __new_result
292 = std::__search(__first1, __last1, __first2, __last2, __comp);
293 if (__new_result == __last1)
297 __result = __new_result;
298 __first1 = __new_result;
305 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
306 typename _BinaryPredicate>
308 _BidirectionalIterator1
309 __find_end(_BidirectionalIterator1 __first1,
310 _BidirectionalIterator1 __last1,
311 _BidirectionalIterator2 __first2,
312 _BidirectionalIterator2 __last2,
313 bidirectional_iterator_tag, bidirectional_iterator_tag,
314 _BinaryPredicate __comp)
317 __glibcxx_function_requires(_BidirectionalIteratorConcept<
318 _BidirectionalIterator1>)
319 __glibcxx_function_requires(_BidirectionalIteratorConcept<
320 _BidirectionalIterator2>)
322 typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1;
323 typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2;
325 _RevIterator1 __rlast1(__first1);
326 _RevIterator2 __rlast2(__first2);
327 _RevIterator1 __rresult =
std::__search(_RevIterator1(__last1), __rlast1,
328 _RevIterator2(__last2), __rlast2,
331 if (__rresult == __rlast1)
335 _BidirectionalIterator1 __result = __rresult.base();
367 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
369 inline _ForwardIterator1
370 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
371 _ForwardIterator2 __first2, _ForwardIterator2 __last2)
374 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
375 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
376 __glibcxx_function_requires(_EqualOpConcept<
379 __glibcxx_requires_valid_range(__first1, __last1);
380 __glibcxx_requires_valid_range(__first2, __last2);
382 return std::__find_end(__first1, __last1, __first2, __last2,
385 __gnu_cxx::__ops::__iter_equal_to_iter());
416 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
417 typename _BinaryPredicate>
419 inline _ForwardIterator1
420 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
421 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
422 _BinaryPredicate __comp)
425 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
426 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
427 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
430 __glibcxx_requires_valid_range(__first1, __last1);
431 __glibcxx_requires_valid_range(__first2, __last2);
433 return std::__find_end(__first1, __last1, __first2, __last2,
436 __gnu_cxx::__ops::__iter_comp_iter(__comp));
439#if __cplusplus >= 201103L
452 template<
typename _InputIterator,
typename _Predicate>
455 all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
456 {
return __last == std::find_if_not(__first, __last, __pred); }
470 template<
typename _InputIterator,
typename _Predicate>
473 none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
474 {
return __last == _GLIBCXX_STD_A::find_if(__first, __last, __pred); }
489 template<
typename _InputIterator,
typename _Predicate>
492 any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
493 {
return !std::none_of(__first, __last, __pred); }
505 template<
typename _InputIterator,
typename _Predicate>
507 inline _InputIterator
508 find_if_not(_InputIterator __first, _InputIterator __last,
512 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
513 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
515 __glibcxx_requires_valid_range(__first, __last);
517 __gnu_cxx::__ops::__pred_iter(__pred));
530 template<
typename _InputIterator,
typename _Predicate>
533 is_partitioned(_InputIterator __first, _InputIterator __last,
536 __first = std::find_if_not(__first, __last, __pred);
537 if (__first == __last)
540 return std::none_of(__first, __last, __pred);
552 template<
typename _ForwardIterator,
typename _Predicate>
555 partition_point(_ForwardIterator __first, _ForwardIterator __last,
559 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
560 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
564 __glibcxx_requires_valid_range(__first, __last);
573 _DistanceType __half = __len >> 1;
574 _ForwardIterator __middle = __first;
576 if (__pred(*__middle))
580 __len = __len - __half - 1;
589 template<
typename _InputIterator,
typename _OutputIterator,
593 __remove_copy_if(_InputIterator __first, _InputIterator __last,
594 _OutputIterator __result, _Predicate __pred)
596 for (; __first != __last; ++__first)
597 if (!__pred(__first))
599 *__result = *__first;
619 template<
typename _InputIterator,
typename _OutputIterator,
typename _Tp>
621 inline _OutputIterator
622 remove_copy(_InputIterator __first, _InputIterator __last,
623 _OutputIterator __result,
const _Tp& __value)
626 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
627 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
629 __glibcxx_function_requires(_EqualOpConcept<
631 __glibcxx_requires_valid_range(__first, __last);
633 return std::__remove_copy_if(__first, __last, __result,
634 __gnu_cxx::__ops::__iter_equals_val(__value));
652 template<
typename _InputIterator,
typename _OutputIterator,
655 inline _OutputIterator
656 remove_copy_if(_InputIterator __first, _InputIterator __last,
657 _OutputIterator __result, _Predicate __pred)
660 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
661 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
663 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
665 __glibcxx_requires_valid_range(__first, __last);
667 return std::__remove_copy_if(__first, __last, __result,
668 __gnu_cxx::__ops::__pred_iter(__pred));
671#if __cplusplus >= 201103L
687 template<
typename _InputIterator,
typename _OutputIterator,
691 copy_if(_InputIterator __first, _InputIterator __last,
692 _OutputIterator __result, _Predicate __pred)
695 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
696 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
698 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
700 __glibcxx_requires_valid_range(__first, __last);
702 for (; __first != __last; ++__first)
703 if (__pred(*__first))
705 *__result = *__first;
711 template<
typename _InputIterator,
typename _Size,
typename _OutputIterator>
714 __copy_n(_InputIterator __first, _Size __n,
715 _OutputIterator __result, input_iterator_tag)
717 return std::__niter_wrap(__result,
718 __copy_n_a(__first, __n,
719 std::__niter_base(__result),
true));
722 template<
typename _RandomAccessIterator,
typename _Size,
723 typename _OutputIterator>
725 inline _OutputIterator
726 __copy_n(_RandomAccessIterator __first, _Size __n,
727 _OutputIterator __result, random_access_iterator_tag)
728 {
return std::copy(__first, __first + __n, __result); }
743 template<
typename _InputIterator,
typename _Size,
typename _OutputIterator>
745 inline _OutputIterator
746 copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
749 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
750 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
753 const auto __n2 = std::__size_to_integer(__n);
757 __glibcxx_requires_can_increment(__first, __n2);
758 __glibcxx_requires_can_increment(__result, __n2);
760 return std::__copy_n(__first, __n2, __result,
779 template<
typename _InputIterator,
typename _OutputIterator1,
780 typename _OutputIterator2,
typename _Predicate>
782 pair<_OutputIterator1, _OutputIterator2>
783 partition_copy(_InputIterator __first, _InputIterator __last,
784 _OutputIterator1 __out_true, _OutputIterator2 __out_false,
788 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
789 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator1,
791 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator2,
793 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
795 __glibcxx_requires_valid_range(__first, __last);
797 for (; __first != __last; ++__first)
798 if (__pred(*__first))
800 *__out_true = *__first;
805 *__out_false = *__first;
830 template<
typename _ForwardIterator,
typename _Tp>
832 inline _ForwardIterator
833 remove(_ForwardIterator __first, _ForwardIterator __last,
837 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
839 __glibcxx_function_requires(_EqualOpConcept<
841 __glibcxx_requires_valid_range(__first, __last);
843 return std::__remove_if(__first, __last,
844 __gnu_cxx::__ops::__iter_equals_val(__value));
864 template<
typename _ForwardIterator,
typename _Predicate>
866 inline _ForwardIterator
867 remove_if(_ForwardIterator __first, _ForwardIterator __last,
871 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
873 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
875 __glibcxx_requires_valid_range(__first, __last);
877 return std::__remove_if(__first, __last,
878 __gnu_cxx::__ops::__pred_iter(__pred));
881 template<
typename _ForwardIterator,
typename _BinaryPredicate>
884 __adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
885 _BinaryPredicate __binary_pred)
887 if (__first == __last)
889 _ForwardIterator __next = __first;
890 while (++__next != __last)
892 if (__binary_pred(__first, __next))
899 template<
typename _ForwardIterator,
typename _BinaryPredicate>
902 __unique(_ForwardIterator __first, _ForwardIterator __last,
903 _BinaryPredicate __binary_pred)
906 __first = std::__adjacent_find(__first, __last, __binary_pred);
907 if (__first == __last)
911 _ForwardIterator __dest = __first;
913 while (++__first != __last)
914 if (!__binary_pred(__dest, __first))
915 *++__dest = _GLIBCXX_MOVE(*__first);
933 template<
typename _ForwardIterator>
935 inline _ForwardIterator
936 unique(_ForwardIterator __first, _ForwardIterator __last)
939 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
941 __glibcxx_function_requires(_EqualityComparableConcept<
943 __glibcxx_requires_valid_range(__first, __last);
945 return std::__unique(__first, __last,
946 __gnu_cxx::__ops::__iter_equal_to_iter());
964 template<
typename _ForwardIterator,
typename _BinaryPredicate>
966 inline _ForwardIterator
967 unique(_ForwardIterator __first, _ForwardIterator __last,
968 _BinaryPredicate __binary_pred)
971 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
973 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
976 __glibcxx_requires_valid_range(__first, __last);
978 return std::__unique(__first, __last,
979 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
988 template<
typename _ForwardIterator,
typename _OutputIterator,
989 typename _BinaryPredicate>
993 _OutputIterator __result, _BinaryPredicate __binary_pred,
997 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1001 _ForwardIterator __next = __first;
1002 *__result = *__first;
1003 while (++__next != __last)
1004 if (!__binary_pred(__first, __next))
1007 *++__result = *__first;
1018 template<
typename _InputIterator,
typename _OutputIterator,
1019 typename _BinaryPredicate>
1020 _GLIBCXX20_CONSTEXPR
1023 _OutputIterator __result, _BinaryPredicate __binary_pred,
1027 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1032 __decltype(__gnu_cxx::__ops::__iter_comp_val(__binary_pred))
1034 = __gnu_cxx::__ops::__iter_comp_val(__binary_pred);
1035 *__result = __value;
1036 while (++__first != __last)
1037 if (!__rebound_pred(__first, __value))
1040 *++__result = __value;
1051 template<
typename _InputIterator,
typename _ForwardIterator,
1052 typename _BinaryPredicate>
1053 _GLIBCXX20_CONSTEXPR
1056 _ForwardIterator __result, _BinaryPredicate __binary_pred,
1060 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
1063 *__result = *__first;
1064 while (++__first != __last)
1065 if (!__binary_pred(__result, __first))
1066 *++__result = *__first;
1075 template<
typename _B
idirectionalIterator>
1076 _GLIBCXX20_CONSTEXPR
1078 __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last,
1082 if (__first == __last || __first == --__last)
1086 std::iter_swap(__first, __last);
1096 template<
typename _RandomAccessIterator>
1097 _GLIBCXX20_CONSTEXPR
1099 __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last,
1102 if (__first == __last)
1105 while (__first < __last)
1107 std::iter_swap(__first, __last);
1125 template<
typename _B
idirectionalIterator>
1126 _GLIBCXX20_CONSTEXPR
1128 reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
1131 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
1132 _BidirectionalIterator>)
1133 __glibcxx_requires_valid_range(__first, __last);
1153 template<
typename _B
idirectionalIterator,
typename _OutputIterator>
1154 _GLIBCXX20_CONSTEXPR
1156 reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last,
1157 _OutputIterator __result)
1160 __glibcxx_function_requires(_BidirectionalIteratorConcept<
1161 _BidirectionalIterator>)
1162 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1164 __glibcxx_requires_valid_range(__first, __last);
1166 while (__first != __last)
1169 *__result = *__last;
1179 template<
typename _Eucl
ideanRingElement>
1180 _GLIBCXX20_CONSTEXPR
1181 _EuclideanRingElement
1182 __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
1186 _EuclideanRingElement __t = __m % __n;
1193 inline namespace _V2
1197 template<
typename _ForwardIterator>
1198 _GLIBCXX20_CONSTEXPR
1201 _ForwardIterator __middle,
1202 _ForwardIterator __last,
1205 if (__first == __middle)
1207 else if (__last == __middle)
1210 _ForwardIterator __first2 = __middle;
1213 std::iter_swap(__first, __first2);
1216 if (__first == __middle)
1217 __middle = __first2;
1219 while (__first2 != __last);
1221 _ForwardIterator __ret = __first;
1223 __first2 = __middle;
1225 while (__first2 != __last)
1227 std::iter_swap(__first, __first2);
1230 if (__first == __middle)
1231 __middle = __first2;
1232 else if (__first2 == __last)
1233 __first2 = __middle;
1239 template<
typename _B
idirectionalIterator>
1240 _GLIBCXX20_CONSTEXPR
1241 _BidirectionalIterator
1243 _BidirectionalIterator __middle,
1244 _BidirectionalIterator __last,
1248 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
1249 _BidirectionalIterator>)
1251 if (__first == __middle)
1253 else if (__last == __middle)
1259 while (__first != __middle && __middle != __last)
1261 std::iter_swap(__first, --__last);
1265 if (__first == __middle)
1278 template<
typename _RandomAccessIterator>
1279 _GLIBCXX20_CONSTEXPR
1280 _RandomAccessIterator
1282 _RandomAccessIterator __middle,
1283 _RandomAccessIterator __last,
1287 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
1288 _RandomAccessIterator>)
1290 if (__first == __middle)
1292 else if (__last == __middle)
1300 _Distance __n = __last - __first;
1301 _Distance __k = __middle - __first;
1303 if (__k == __n - __k)
1305 std::swap_ranges(__first, __middle, __middle);
1309 _RandomAccessIterator __p = __first;
1310 _RandomAccessIterator __ret = __first + (__last - __middle);
1314 if (__k < __n - __k)
1316 if (__is_pod(_ValueType) && __k == 1)
1318 _ValueType __t = _GLIBCXX_MOVE(*__p);
1319 _GLIBCXX_MOVE3(__p + 1, __p + __n, __p);
1320 *(__p + __n - 1) = _GLIBCXX_MOVE(__t);
1323 _RandomAccessIterator __q = __p + __k;
1324 for (_Distance __i = 0; __i < __n - __k; ++ __i)
1326 std::iter_swap(__p, __q);
1339 if (__is_pod(_ValueType) && __k == 1)
1341 _ValueType __t = _GLIBCXX_MOVE(*(__p + __n - 1));
1342 _GLIBCXX_MOVE_BACKWARD3(__p, __p + __n - 1, __p + __n);
1343 *__p = _GLIBCXX_MOVE(__t);
1346 _RandomAccessIterator __q = __p + __n;
1348 for (_Distance __i = 0; __i < __n - __k; ++ __i)
1352 std::iter_swap(__p, __q);
1385 template<
typename _ForwardIterator>
1386 _GLIBCXX20_CONSTEXPR
1387 inline _ForwardIterator
1388 rotate(_ForwardIterator __first, _ForwardIterator __middle,
1389 _ForwardIterator __last)
1392 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1394 __glibcxx_requires_valid_range(__first, __middle);
1395 __glibcxx_requires_valid_range(__middle, __last);
1423 template<
typename _ForwardIterator,
typename _OutputIterator>
1424 _GLIBCXX20_CONSTEXPR
1425 inline _OutputIterator
1426 rotate_copy(_ForwardIterator __first, _ForwardIterator __middle,
1427 _ForwardIterator __last, _OutputIterator __result)
1430 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1431 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1433 __glibcxx_requires_valid_range(__first, __middle);
1434 __glibcxx_requires_valid_range(__middle, __last);
1436 return std::copy(__first, __middle,
1437 std::copy(__middle, __last, __result));
1441 template<
typename _ForwardIterator,
typename _Predicate>
1442 _GLIBCXX20_CONSTEXPR
1447 if (__first == __last)
1450 while (__pred(*__first))
1451 if (++__first == __last)
1454 _ForwardIterator __next = __first;
1456 while (++__next != __last)
1457 if (__pred(*__next))
1459 std::iter_swap(__first, __next);
1467 template<
typename _B
idirectionalIterator,
typename _Predicate>
1468 _GLIBCXX20_CONSTEXPR
1469 _BidirectionalIterator
1470 __partition(_BidirectionalIterator __first, _BidirectionalIterator __last,
1476 if (__first == __last)
1478 else if (__pred(*__first))
1484 if (__first == __last)
1486 else if (!
bool(__pred(*__last)))
1490 std::iter_swap(__first, __last);
1503 template<
typename _ForwardIterator,
typename _Pointer,
typename _Predicate,
1507 _ForwardIterator __last,
1508 _Predicate __pred, _Distance __len,
1510 _Distance __buffer_size)
1515 if (__len <= __buffer_size)
1517 _ForwardIterator __result1 = __first;
1518 _Pointer __result2 = __buffer;
1523 *__result2 = _GLIBCXX_MOVE(*__first);
1526 for (; __first != __last; ++__first)
1527 if (__pred(__first))
1529 *__result1 = _GLIBCXX_MOVE(*__first);
1534 *__result2 = _GLIBCXX_MOVE(*__first);
1538 _GLIBCXX_MOVE3(__buffer, __result2, __result1);
1542 _ForwardIterator __middle = __first;
1544 _ForwardIterator __left_split =
1546 __len / 2, __buffer,
1551 _Distance __right_len = __len - __len / 2;
1552 _ForwardIterator __right_split =
1559 __buffer, __buffer_size);
1561 return std::rotate(__left_split, __middle, __right_split);
1564 template<
typename _ForwardIterator,
typename _Predicate>
1566 __stable_partition(_ForwardIterator __first, _ForwardIterator __last,
1571 if (__first == __last)
1574 typedef typename iterator_traits<_ForwardIterator>::value_type
1576 typedef typename iterator_traits<_ForwardIterator>::difference_type
1579 _Temporary_buffer<_ForwardIterator, _ValueType>
1583 _DistanceType(__buf.requested_size()),
1585 _DistanceType(__buf.size()));
1605 template<
typename _ForwardIterator,
typename _Predicate>
1606 inline _ForwardIterator
1607 stable_partition(_ForwardIterator __first, _ForwardIterator __last,
1611 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
1613 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
1615 __glibcxx_requires_valid_range(__first, __last);
1617 return std::__stable_partition(__first, __last,
1618 __gnu_cxx::__ops::__pred_iter(__pred));
1622 template<
typename _RandomAccessIterator,
typename _Compare>
1623 _GLIBCXX20_CONSTEXPR
1626 _RandomAccessIterator __middle,
1627 _RandomAccessIterator __last, _Compare __comp)
1629 std::__make_heap(__first, __middle, __comp);
1630 for (_RandomAccessIterator __i = __middle; __i < __last; ++__i)
1631 if (__comp(__i, __first))
1632 std::__pop_heap(__first, __middle, __i, __comp);
1637 template<
typename _InputIterator,
typename _RandomAccessIterator,
1639 _GLIBCXX20_CONSTEXPR
1640 _RandomAccessIterator
1641 __partial_sort_copy(_InputIterator __first, _InputIterator __last,
1642 _RandomAccessIterator __result_first,
1643 _RandomAccessIterator __result_last,
1646 typedef typename iterator_traits<_InputIterator>::value_type
1648 typedef iterator_traits<_RandomAccessIterator> _RItTraits;
1649 typedef typename _RItTraits::difference_type _DistanceType;
1651 if (__result_first == __result_last)
1652 return __result_last;
1653 _RandomAccessIterator __result_real_last = __result_first;
1654 while (__first != __last && __result_real_last != __result_last)
1656 *__result_real_last = *__first;
1657 ++__result_real_last;
1661 std::__make_heap(__result_first, __result_real_last, __comp);
1662 while (__first != __last)
1664 if (__comp(__first, __result_first))
1665 std::__adjust_heap(__result_first, _DistanceType(0),
1666 _DistanceType(__result_real_last
1668 _InputValueType(*__first), __comp);
1671 std::__sort_heap(__result_first, __result_real_last, __comp);
1672 return __result_real_last;
1693 template<
typename _InputIterator,
typename _RandomAccessIterator>
1694 _GLIBCXX20_CONSTEXPR
1695 inline _RandomAccessIterator
1696 partial_sort_copy(_InputIterator __first, _InputIterator __last,
1697 _RandomAccessIterator __result_first,
1698 _RandomAccessIterator __result_last)
1700#ifdef _GLIBCXX_CONCEPT_CHECKS
1708 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
1709 __glibcxx_function_requires(_ConvertibleConcept<_InputValueType,
1711 __glibcxx_function_requires(_LessThanOpConcept<_InputValueType,
1713 __glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>)
1714 __glibcxx_requires_valid_range(__first, __last);
1715 __glibcxx_requires_irreflexive(__first, __last);
1716 __glibcxx_requires_valid_range(__result_first, __result_last);
1718 return std::__partial_sort_copy(__first, __last,
1719 __result_first, __result_last,
1720 __gnu_cxx::__ops::__iter_less_iter());
1743 template<
typename _InputIterator,
typename _RandomAccessIterator,
1745 _GLIBCXX20_CONSTEXPR
1746 inline _RandomAccessIterator
1747 partial_sort_copy(_InputIterator __first, _InputIterator __last,
1748 _RandomAccessIterator __result_first,
1749 _RandomAccessIterator __result_last,
1752#ifdef _GLIBCXX_CONCEPT_CHECKS
1760 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
1761 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
1762 _RandomAccessIterator>)
1763 __glibcxx_function_requires(_ConvertibleConcept<_InputValueType,
1765 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
1766 _InputValueType, _OutputValueType>)
1767 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
1768 _OutputValueType, _OutputValueType>)
1769 __glibcxx_requires_valid_range(__first, __last);
1770 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
1771 __glibcxx_requires_valid_range(__result_first, __result_last);
1773 return std::__partial_sort_copy(__first, __last,
1774 __result_first, __result_last,
1775 __gnu_cxx::__ops::__iter_comp_iter(__comp));
1779 template<
typename _RandomAccessIterator,
typename _Compare>
1780 _GLIBCXX20_CONSTEXPR
1786 __val = _GLIBCXX_MOVE(*__last);
1787 _RandomAccessIterator __next = __last;
1789 while (__comp(__val, __next))
1791 *__last = _GLIBCXX_MOVE(*__next);
1795 *__last = _GLIBCXX_MOVE(__val);
1799 template<
typename _RandomAccessIterator,
typename _Compare>
1800 _GLIBCXX20_CONSTEXPR
1803 _RandomAccessIterator __last, _Compare __comp)
1805 if (__first == __last)
return;
1807 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
1809 if (__comp(__i, __first))
1812 __val = _GLIBCXX_MOVE(*__i);
1813 _GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1);
1814 *__first = _GLIBCXX_MOVE(__val);
1818 __gnu_cxx::__ops::__val_comp_iter(__comp));
1823 template<
typename _RandomAccessIterator,
typename _Compare>
1824 _GLIBCXX20_CONSTEXPR
1827 _RandomAccessIterator __last, _Compare __comp)
1829 for (_RandomAccessIterator __i = __first; __i != __last; ++__i)
1831 __gnu_cxx::__ops::__val_comp_iter(__comp));
1838 enum { _S_threshold = 16 };
1841 template<
typename _RandomAccessIterator,
typename _Compare>
1842 _GLIBCXX20_CONSTEXPR
1845 _RandomAccessIterator __last, _Compare __comp)
1847 if (__last - __first >
int(_S_threshold))
1858 template<
typename _RandomAccessIterator,
typename _Compare>
1859 _GLIBCXX20_CONSTEXPR
1860 _RandomAccessIterator
1862 _RandomAccessIterator __last,
1863 _RandomAccessIterator __pivot, _Compare __comp)
1867 while (__comp(__first, __pivot))
1870 while (__comp(__pivot, __last))
1872 if (!(__first < __last))
1874 std::iter_swap(__first, __last);
1880 template<
typename _RandomAccessIterator,
typename _Compare>
1881 _GLIBCXX20_CONSTEXPR
1882 inline _RandomAccessIterator
1884 _RandomAccessIterator __last, _Compare __comp)
1886 _RandomAccessIterator __mid = __first + (__last - __first) / 2;
1892 template<
typename _RandomAccessIterator,
typename _Compare>
1893 _GLIBCXX20_CONSTEXPR
1895 __partial_sort(_RandomAccessIterator __first,
1896 _RandomAccessIterator __middle,
1897 _RandomAccessIterator __last,
1901 std::__sort_heap(__first, __middle, __comp);
1905 template<
typename _RandomAccessIterator,
typename _Size,
typename _Compare>
1906 _GLIBCXX20_CONSTEXPR
1909 _RandomAccessIterator __last,
1910 _Size __depth_limit, _Compare __comp)
1912 while (__last - __first >
int(_S_threshold))
1914 if (__depth_limit == 0)
1916 std::__partial_sort(__first, __last, __last, __comp);
1920 _RandomAccessIterator __cut =
1929 template<
typename _RandomAccessIterator,
typename _Compare>
1930 _GLIBCXX20_CONSTEXPR
1932 __sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
1935 if (__first != __last)
1944 template<
typename _RandomAccessIterator,
typename _Size,
typename _Compare>
1945 _GLIBCXX20_CONSTEXPR
1947 __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth,
1948 _RandomAccessIterator __last, _Size __depth_limit,
1951 while (__last - __first > 3)
1953 if (__depth_limit == 0)
1957 std::iter_swap(__first, __nth);
1961 _RandomAccessIterator __cut =
1991 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
1992 _GLIBCXX20_CONSTEXPR
1993 inline _ForwardIterator
1994 lower_bound(_ForwardIterator __first, _ForwardIterator __last,
1995 const _Tp& __val, _Compare __comp)
1998 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1999 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2001 __glibcxx_requires_partitioned_lower_pred(__first, __last,
2004 return std::__lower_bound(__first, __last, __val,
2005 __gnu_cxx::__ops::__iter_comp_val(__comp));
2008 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2009 _GLIBCXX20_CONSTEXPR
2011 __upper_bound(_ForwardIterator __first, _ForwardIterator __last,
2012 const _Tp& __val, _Compare __comp)
2014 typedef typename iterator_traits<_ForwardIterator>::difference_type
2021 _DistanceType __half = __len >> 1;
2022 _ForwardIterator __middle = __first;
2024 if (__comp(__val, __middle))
2030 __len = __len - __half - 1;
2047 template<
typename _ForwardIterator,
typename _Tp>
2048 _GLIBCXX20_CONSTEXPR
2049 inline _ForwardIterator
2050 upper_bound(_ForwardIterator __first, _ForwardIterator __last,
2054 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2055 __glibcxx_function_requires(_LessThanOpConcept<
2057 __glibcxx_requires_partitioned_upper(__first, __last, __val);
2059 return std::__upper_bound(__first, __last, __val,
2060 __gnu_cxx::__ops::__val_less_iter());
2078 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2079 _GLIBCXX20_CONSTEXPR
2080 inline _ForwardIterator
2081 upper_bound(_ForwardIterator __first, _ForwardIterator __last,
2082 const _Tp& __val, _Compare __comp)
2085 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2086 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2088 __glibcxx_requires_partitioned_upper_pred(__first, __last,
2091 return std::__upper_bound(__first, __last, __val,
2092 __gnu_cxx::__ops::__val_comp_iter(__comp));
2095 template<
typename _ForwardIterator,
typename _Tp,
2096 typename _CompareItTp,
typename _CompareTpIt>
2097 _GLIBCXX20_CONSTEXPR
2098 pair<_ForwardIterator, _ForwardIterator>
2099 __equal_range(_ForwardIterator __first, _ForwardIterator __last,
2101 _CompareItTp __comp_it_val, _CompareTpIt __comp_val_it)
2103 typedef typename iterator_traits<_ForwardIterator>::difference_type
2110 _DistanceType __half = __len >> 1;
2111 _ForwardIterator __middle = __first;
2113 if (__comp_it_val(__middle, __val))
2117 __len = __len - __half - 1;
2119 else if (__comp_val_it(__val, __middle))
2123 _ForwardIterator __left
2124 = std::__lower_bound(__first, __middle, __val, __comp_it_val);
2126 _ForwardIterator __right
2127 = std::__upper_bound(++__middle, __first, __val, __comp_val_it);
2128 return pair<_ForwardIterator, _ForwardIterator>(__left, __right);
2131 return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
2151 template<
typename _ForwardIterator,
typename _Tp>
2152 _GLIBCXX20_CONSTEXPR
2153 inline pair<_ForwardIterator, _ForwardIterator>
2154 equal_range(_ForwardIterator __first, _ForwardIterator __last,
2158 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2159 __glibcxx_function_requires(_LessThanOpConcept<
2161 __glibcxx_function_requires(_LessThanOpConcept<
2163 __glibcxx_requires_partitioned_lower(__first, __last, __val);
2164 __glibcxx_requires_partitioned_upper(__first, __last, __val);
2166 return std::__equal_range(__first, __last, __val,
2167 __gnu_cxx::__ops::__iter_less_val(),
2168 __gnu_cxx::__ops::__val_less_iter());
2188 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2189 _GLIBCXX20_CONSTEXPR
2190 inline pair<_ForwardIterator, _ForwardIterator>
2191 equal_range(_ForwardIterator __first, _ForwardIterator __last,
2192 const _Tp& __val, _Compare __comp)
2195 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2196 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2198 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2200 __glibcxx_requires_partitioned_lower_pred(__first, __last,
2202 __glibcxx_requires_partitioned_upper_pred(__first, __last,
2205 return std::__equal_range(__first, __last, __val,
2206 __gnu_cxx::__ops::__iter_comp_val(__comp),
2207 __gnu_cxx::__ops::__val_comp_iter(__comp));
2222 template<
typename _ForwardIterator,
typename _Tp>
2223 _GLIBCXX20_CONSTEXPR
2225 binary_search(_ForwardIterator __first, _ForwardIterator __last,
2229 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2230 __glibcxx_function_requires(_LessThanOpConcept<
2232 __glibcxx_requires_partitioned_lower(__first, __last, __val);
2233 __glibcxx_requires_partitioned_upper(__first, __last, __val);
2235 _ForwardIterator __i
2236 = std::__lower_bound(__first, __last, __val,
2237 __gnu_cxx::__ops::__iter_less_val());
2238 return __i != __last && !(__val < *__i);
2256 template<
typename _ForwardIterator,
typename _Tp,
typename _Compare>
2257 _GLIBCXX20_CONSTEXPR
2259 binary_search(_ForwardIterator __first, _ForwardIterator __last,
2260 const _Tp& __val, _Compare __comp)
2263 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2264 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2266 __glibcxx_requires_partitioned_lower_pred(__first, __last,
2268 __glibcxx_requires_partitioned_upper_pred(__first, __last,
2271 _ForwardIterator __i
2272 = std::__lower_bound(__first, __last, __val,
2273 __gnu_cxx::__ops::__iter_comp_val(__comp));
2274 return __i != __last && !bool(__comp(__val, *__i));
2280 template<
typename _InputIterator1,
typename _InputIterator2,
2281 typename _OutputIterator,
typename _Compare>
2284 _InputIterator2 __first2, _InputIterator2 __last2,
2285 _OutputIterator __result, _Compare __comp)
2287 while (__first1 != __last1 && __first2 != __last2)
2289 if (__comp(__first2, __first1))
2291 *__result = _GLIBCXX_MOVE(*__first2);
2296 *__result = _GLIBCXX_MOVE(*__first1);
2301 if (__first1 != __last1)
2302 _GLIBCXX_MOVE3(__first1, __last1, __result);
2306 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
2307 typename _BidirectionalIterator3,
typename _Compare>
2310 _BidirectionalIterator1 __last1,
2311 _BidirectionalIterator2 __first2,
2312 _BidirectionalIterator2 __last2,
2313 _BidirectionalIterator3 __result,
2316 if (__first1 == __last1)
2318 _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result);
2321 else if (__first2 == __last2)
2328 if (__comp(__last2, __last1))
2330 *--__result = _GLIBCXX_MOVE(*__last1);
2331 if (__first1 == __last1)
2333 _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result);
2340 *--__result = _GLIBCXX_MOVE(*__last2);
2341 if (__first2 == __last2)
2349 template<
typename _BidirectionalIterator1,
typename _BidirectionalIterator2,
2351 _BidirectionalIterator1
2353 _BidirectionalIterator1 __middle,
2354 _BidirectionalIterator1 __last,
2355 _Distance __len1, _Distance __len2,
2356 _BidirectionalIterator2 __buffer,
2357 _Distance __buffer_size)
2359 _BidirectionalIterator2 __buffer_end;
2360 if (__len1 > __len2 && __len2 <= __buffer_size)
2364 __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
2365 _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last);
2366 return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first);
2371 else if (__len1 <= __buffer_size)
2375 __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
2376 _GLIBCXX_MOVE3(__middle, __last, __first);
2377 return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last);
2383 return std::rotate(__first, __middle, __last);
2387 template<
typename _BidirectionalIterator,
typename _Distance,
2388 typename _Pointer,
typename _Compare>
2391 _BidirectionalIterator __middle,
2392 _BidirectionalIterator __last,
2393 _Distance __len1, _Distance __len2,
2394 _Pointer __buffer, _Distance __buffer_size,
2397 if (__len1 <= __len2 && __len1 <= __buffer_size)
2399 _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
2403 else if (__len2 <= __buffer_size)
2405 _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
2407 __buffer_end, __last, __comp);
2411 _BidirectionalIterator __first_cut = __first;
2412 _BidirectionalIterator __second_cut = __middle;
2413 _Distance __len11 = 0;
2414 _Distance __len22 = 0;
2415 if (__len1 > __len2)
2417 __len11 = __len1 / 2;
2420 = std::__lower_bound(__middle, __last, *__first_cut,
2421 __gnu_cxx::__ops::__iter_comp_val(__comp));
2426 __len22 = __len2 / 2;
2429 = std::__upper_bound(__first, __middle, *__second_cut,
2430 __gnu_cxx::__ops::__val_comp_iter(__comp));
2434 _BidirectionalIterator __new_middle
2436 __len1 - __len11, __len22, __buffer,
2439 __len22, __buffer, __buffer_size, __comp);
2442 __len2 - __len22, __buffer,
2443 __buffer_size, __comp);
2448 template<
typename _BidirectionalIterator,
typename _Distance,
2452 _BidirectionalIterator __middle,
2453 _BidirectionalIterator __last,
2454 _Distance __len1, _Distance __len2,
2457 if (__len1 == 0 || __len2 == 0)
2460 if (__len1 + __len2 == 2)
2462 if (__comp(__middle, __first))
2463 std::iter_swap(__first, __middle);
2467 _BidirectionalIterator __first_cut = __first;
2468 _BidirectionalIterator __second_cut = __middle;
2469 _Distance __len11 = 0;
2470 _Distance __len22 = 0;
2471 if (__len1 > __len2)
2473 __len11 = __len1 / 2;
2476 = std::__lower_bound(__middle, __last, *__first_cut,
2477 __gnu_cxx::__ops::__iter_comp_val(__comp));
2482 __len22 = __len2 / 2;
2485 = std::__upper_bound(__first, __middle, *__second_cut,
2486 __gnu_cxx::__ops::__val_comp_iter(__comp));
2490 _BidirectionalIterator __new_middle
2491 = std::rotate(__first_cut, __middle, __second_cut);
2493 __len11, __len22, __comp);
2495 __len1 - __len11, __len2 - __len22, __comp);
2498 template<
typename _B
idirectionalIterator,
typename _Compare>
2500 __inplace_merge(_BidirectionalIterator __first,
2501 _BidirectionalIterator __middle,
2502 _BidirectionalIterator __last,
2505 typedef typename iterator_traits<_BidirectionalIterator>::value_type
2507 typedef typename iterator_traits<_BidirectionalIterator>::difference_type
2509 typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf;
2511 if (__first == __middle || __middle == __last)
2514 const _DistanceType __len1 =
std::distance(__first, __middle);
2515 const _DistanceType __len2 =
std::distance(__middle, __last);
2519 _TmpBuf __buf(__first,
std::min(__len1, __len2));
2521 if (__buf.begin() == 0)
2523 (__first, __middle, __last, __len1, __len2, __comp);
2526 (__first, __middle, __last, __len1, __len2, __buf.begin(),
2527 _DistanceType(__buf.size()), __comp);
2548 template<
typename _B
idirectionalIterator>
2550 inplace_merge(_BidirectionalIterator __first,
2551 _BidirectionalIterator __middle,
2552 _BidirectionalIterator __last)
2555 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
2556 _BidirectionalIterator>)
2557 __glibcxx_function_requires(_LessThanComparableConcept<
2559 __glibcxx_requires_sorted(__first, __middle);
2560 __glibcxx_requires_sorted(__middle, __last);
2561 __glibcxx_requires_irreflexive(__first, __last);
2563 std::__inplace_merge(__first, __middle, __last,
2564 __gnu_cxx::__ops::__iter_less_iter());
2589 template<
typename _B
idirectionalIterator,
typename _Compare>
2591 inplace_merge(_BidirectionalIterator __first,
2592 _BidirectionalIterator __middle,
2593 _BidirectionalIterator __last,
2597 __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<
2598 _BidirectionalIterator>)
2599 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2602 __glibcxx_requires_sorted_pred(__first, __middle, __comp);
2603 __glibcxx_requires_sorted_pred(__middle, __last, __comp);
2604 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
2606 std::__inplace_merge(__first, __middle, __last,
2607 __gnu_cxx::__ops::__iter_comp_iter(__comp));
2612 template<
typename _InputIterator,
typename _OutputIterator,
2616 _InputIterator __first2, _InputIterator __last2,
2617 _OutputIterator __result, _Compare __comp)
2619 while (__first1 != __last1 && __first2 != __last2)
2621 if (__comp(__first2, __first1))
2623 *__result = _GLIBCXX_MOVE(*__first2);
2628 *__result = _GLIBCXX_MOVE(*__first1);
2633 return _GLIBCXX_MOVE3(__first2, __last2,
2634 _GLIBCXX_MOVE3(__first1, __last1,
2638 template<
typename _RandomAccessIterator1,
typename _RandomAccessIterator2,
2639 typename _Distance,
typename _Compare>
2641 __merge_sort_loop(_RandomAccessIterator1 __first,
2642 _RandomAccessIterator1 __last,
2643 _RandomAccessIterator2 __result, _Distance __step_size,
2646 const _Distance __two_step = 2 * __step_size;
2648 while (__last - __first >= __two_step)
2651 __first + __step_size,
2652 __first + __two_step,
2654 __first += __two_step;
2656 __step_size =
std::min(_Distance(__last - __first), __step_size);
2659 __first + __step_size, __last, __result, __comp);
2662 template<
typename _RandomAccessIterator,
typename _Distance,
2664 _GLIBCXX20_CONSTEXPR
2666 __chunk_insertion_sort(_RandomAccessIterator __first,
2667 _RandomAccessIterator __last,
2668 _Distance __chunk_size, _Compare __comp)
2670 while (__last - __first >= __chunk_size)
2673 __first += __chunk_size;
2678 enum { _S_chunk_size = 7 };
2680 template<
typename _RandomAccessIterator,
typename _Po
inter,
typename _Compare>
2682 __merge_sort_with_buffer(_RandomAccessIterator __first,
2683 _RandomAccessIterator __last,
2684 _Pointer __buffer, _Compare __comp)
2686 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
2689 const _Distance __len = __last - __first;
2690 const _Pointer __buffer_last = __buffer + __len;
2692 _Distance __step_size = _S_chunk_size;
2693 std::__chunk_insertion_sort(__first, __last, __step_size, __comp);
2695 while (__step_size < __len)
2697 std::__merge_sort_loop(__first, __last, __buffer,
2698 __step_size, __comp);
2700 std::__merge_sort_loop(__buffer, __buffer_last, __first,
2701 __step_size, __comp);
2706 template<
typename _RandomAccessIterator,
typename _Pointer,
2707 typename _Distance,
typename _Compare>
2709 __stable_sort_adaptive(_RandomAccessIterator __first,
2710 _RandomAccessIterator __last,
2711 _Pointer __buffer, _Distance __buffer_size,
2714 const _Distance __len = (__last - __first + 1) / 2;
2715 const _RandomAccessIterator __middle = __first + __len;
2716 if (__len > __buffer_size)
2718 std::__stable_sort_adaptive(__first, __middle, __buffer,
2719 __buffer_size, __comp);
2720 std::__stable_sort_adaptive(__middle, __last, __buffer,
2721 __buffer_size, __comp);
2725 std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp);
2726 std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp);
2730 _Distance(__middle - __first),
2731 _Distance(__last - __middle),
2732 __buffer, __buffer_size,
2737 template<
typename _RandomAccessIterator,
typename _Compare>
2740 _RandomAccessIterator __last, _Compare __comp)
2742 if (__last - __first < 15)
2747 _RandomAccessIterator __middle = __first + (__last - __first) / 2;
2763 template<
typename _InputIterator1,
typename _InputIterator2,
2765 _GLIBCXX20_CONSTEXPR
2767 __includes(_InputIterator1 __first1, _InputIterator1 __last1,
2768 _InputIterator2 __first2, _InputIterator2 __last2,
2771 while (__first1 != __last1 && __first2 != __last2)
2773 if (__comp(__first2, __first1))
2775 if (!__comp(__first1, __first2))
2780 return __first2 == __last2;
2801 template<
typename _InputIterator1,
typename _InputIterator2>
2802 _GLIBCXX20_CONSTEXPR
2804 includes(_InputIterator1 __first1, _InputIterator1 __last1,
2805 _InputIterator2 __first2, _InputIterator2 __last2)
2808 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
2809 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
2810 __glibcxx_function_requires(_LessThanOpConcept<
2813 __glibcxx_function_requires(_LessThanOpConcept<
2816 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
2817 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
2818 __glibcxx_requires_irreflexive2(__first1, __last1);
2819 __glibcxx_requires_irreflexive2(__first2, __last2);
2821 return std::__includes(__first1, __last1, __first2, __last2,
2822 __gnu_cxx::__ops::__iter_less_iter());
2846 template<
typename _InputIterator1,
typename _InputIterator2,
2848 _GLIBCXX20_CONSTEXPR
2850 includes(_InputIterator1 __first1, _InputIterator1 __last1,
2851 _InputIterator2 __first2, _InputIterator2 __last2,
2855 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
2856 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
2857 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2860 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2863 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
2864 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
2865 __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
2866 __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
2868 return std::__includes(__first1, __last1, __first2, __last2,
2869 __gnu_cxx::__ops::__iter_comp_iter(__comp));
2882 template<
typename _B
idirectionalIterator,
typename _Compare>
2883 _GLIBCXX20_CONSTEXPR
2885 __next_permutation(_BidirectionalIterator __first,
2886 _BidirectionalIterator __last, _Compare __comp)
2888 if (__first == __last)
2890 _BidirectionalIterator __i = __first;
2899 _BidirectionalIterator __ii = __i;
2901 if (__comp(__i, __ii))
2903 _BidirectionalIterator __j = __last;
2904 while (!__comp(__i, --__j))
2906 std::iter_swap(__i, __j);
2932 template<
typename _B
idirectionalIterator>
2933 _GLIBCXX20_CONSTEXPR
2935 next_permutation(_BidirectionalIterator __first,
2936 _BidirectionalIterator __last)
2939 __glibcxx_function_requires(_BidirectionalIteratorConcept<
2940 _BidirectionalIterator>)
2941 __glibcxx_function_requires(_LessThanComparableConcept<
2943 __glibcxx_requires_valid_range(__first, __last);
2944 __glibcxx_requires_irreflexive(__first, __last);
2946 return std::__next_permutation
2947 (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
2965 template<
typename _B
idirectionalIterator,
typename _Compare>
2966 _GLIBCXX20_CONSTEXPR
2968 next_permutation(_BidirectionalIterator __first,
2969 _BidirectionalIterator __last, _Compare __comp)
2972 __glibcxx_function_requires(_BidirectionalIteratorConcept<
2973 _BidirectionalIterator>)
2974 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
2977 __glibcxx_requires_valid_range(__first, __last);
2978 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
2980 return std::__next_permutation
2981 (__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
2984 template<
typename _B
idirectionalIterator,
typename _Compare>
2985 _GLIBCXX20_CONSTEXPR
2987 __prev_permutation(_BidirectionalIterator __first,
2988 _BidirectionalIterator __last, _Compare __comp)
2990 if (__first == __last)
2992 _BidirectionalIterator __i = __first;
3001 _BidirectionalIterator __ii = __i;
3003 if (__comp(__ii, __i))
3005 _BidirectionalIterator __j = __last;
3006 while (!__comp(--__j, __i))
3008 std::iter_swap(__i, __j);
3035 template<
typename _B
idirectionalIterator>
3036 _GLIBCXX20_CONSTEXPR
3038 prev_permutation(_BidirectionalIterator __first,
3039 _BidirectionalIterator __last)
3042 __glibcxx_function_requires(_BidirectionalIteratorConcept<
3043 _BidirectionalIterator>)
3044 __glibcxx_function_requires(_LessThanComparableConcept<
3046 __glibcxx_requires_valid_range(__first, __last);
3047 __glibcxx_requires_irreflexive(__first, __last);
3049 return std::__prev_permutation(__first, __last,
3050 __gnu_cxx::__ops::__iter_less_iter());
3068 template<
typename _B
idirectionalIterator,
typename _Compare>
3069 _GLIBCXX20_CONSTEXPR
3071 prev_permutation(_BidirectionalIterator __first,
3072 _BidirectionalIterator __last, _Compare __comp)
3075 __glibcxx_function_requires(_BidirectionalIteratorConcept<
3076 _BidirectionalIterator>)
3077 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3080 __glibcxx_requires_valid_range(__first, __last);
3081 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
3083 return std::__prev_permutation(__first, __last,
3084 __gnu_cxx::__ops::__iter_comp_iter(__comp));
3090 template<
typename _InputIterator,
typename _OutputIterator,
3091 typename _Predicate,
typename _Tp>
3092 _GLIBCXX20_CONSTEXPR
3094 __replace_copy_if(_InputIterator __first, _InputIterator __last,
3095 _OutputIterator __result,
3096 _Predicate __pred,
const _Tp& __new_value)
3098 for (; __first != __last; ++__first, (void)++__result)
3099 if (__pred(__first))
3100 *__result = __new_value;
3102 *__result = *__first;
3120 template<
typename _InputIterator,
typename _OutputIterator,
typename _Tp>
3121 _GLIBCXX20_CONSTEXPR
3122 inline _OutputIterator
3123 replace_copy(_InputIterator __first, _InputIterator __last,
3124 _OutputIterator __result,
3125 const _Tp& __old_value,
const _Tp& __new_value)
3128 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3129 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
3131 __glibcxx_function_requires(_EqualOpConcept<
3133 __glibcxx_requires_valid_range(__first, __last);
3135 return std::__replace_copy_if(__first, __last, __result,
3136 __gnu_cxx::__ops::__iter_equals_val(__old_value),
3155 template<
typename _InputIterator,
typename _OutputIterator,
3156 typename _Predicate,
typename _Tp>
3157 _GLIBCXX20_CONSTEXPR
3158 inline _OutputIterator
3159 replace_copy_if(_InputIterator __first, _InputIterator __last,
3160 _OutputIterator __result,
3161 _Predicate __pred,
const _Tp& __new_value)
3164 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3165 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
3167 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
3169 __glibcxx_requires_valid_range(__first, __last);
3171 return std::__replace_copy_if(__first, __last, __result,
3172 __gnu_cxx::__ops::__pred_iter(__pred),
3176#if __cplusplus >= 201103L
3184 template<
typename _ForwardIterator>
3185 _GLIBCXX20_CONSTEXPR
3187 is_sorted(_ForwardIterator __first, _ForwardIterator __last)
3188 {
return std::is_sorted_until(__first, __last) == __last; }
3199 template<
typename _ForwardIterator,
typename _Compare>
3200 _GLIBCXX20_CONSTEXPR
3202 is_sorted(_ForwardIterator __first, _ForwardIterator __last,
3204 {
return std::is_sorted_until(__first, __last, __comp) == __last; }
3206 template<
typename _ForwardIterator,
typename _Compare>
3207 _GLIBCXX20_CONSTEXPR
3209 __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
3212 if (__first == __last)
3215 _ForwardIterator __next = __first;
3216 for (++__next; __next != __last; __first = __next, (void)++__next)
3217 if (__comp(__next, __first))
3230 template<
typename _ForwardIterator>
3231 _GLIBCXX20_CONSTEXPR
3232 inline _ForwardIterator
3233 is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
3236 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3237 __glibcxx_function_requires(_LessThanComparableConcept<
3239 __glibcxx_requires_valid_range(__first, __last);
3240 __glibcxx_requires_irreflexive(__first, __last);
3242 return std::__is_sorted_until(__first, __last,
3243 __gnu_cxx::__ops::__iter_less_iter());
3255 template<
typename _ForwardIterator,
typename _Compare>
3256 _GLIBCXX20_CONSTEXPR
3257 inline _ForwardIterator
3258 is_sorted_until(_ForwardIterator __first, _ForwardIterator __last,
3262 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3263 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3266 __glibcxx_requires_valid_range(__first, __last);
3267 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
3269 return std::__is_sorted_until(__first, __last,
3270 __gnu_cxx::__ops::__iter_comp_iter(__comp));
3281 template<
typename _Tp>
3282 _GLIBCXX14_CONSTEXPR
3283 inline pair<const _Tp&, const _Tp&>
3287 __glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
3289 return __b < __a ? pair<const _Tp&, const _Tp&>(__b, __a)
3302 template<
typename _Tp,
typename _Compare>
3303 _GLIBCXX14_CONSTEXPR
3304 inline pair<const _Tp&, const _Tp&>
3305 minmax(
const _Tp& __a,
const _Tp& __b, _Compare __comp)
3311 template<
typename _ForwardIterator,
typename _Compare>
3312 _GLIBCXX14_CONSTEXPR
3313 pair<_ForwardIterator, _ForwardIterator>
3314 __minmax_element(_ForwardIterator __first, _ForwardIterator __last,
3317 _ForwardIterator __next = __first;
3318 if (__first == __last
3319 || ++__next == __last)
3320 return std::make_pair(__first, __first);
3322 _ForwardIterator __min{}, __max{};
3323 if (__comp(__next, __first))
3337 while (__first != __last)
3340 if (++__next == __last)
3342 if (__comp(__first, __min))
3344 else if (!__comp(__first, __max))
3349 if (__comp(__next, __first))
3351 if (__comp(__next, __min))
3353 if (!__comp(__first, __max))
3358 if (__comp(__first, __min))
3360 if (!__comp(__next, __max))
3368 return std::make_pair(__min, __max);
3382 template<
typename _ForwardIterator>
3383 _GLIBCXX14_CONSTEXPR
3384 inline pair<_ForwardIterator, _ForwardIterator>
3385 minmax_element(_ForwardIterator __first, _ForwardIterator __last)
3388 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3389 __glibcxx_function_requires(_LessThanComparableConcept<
3391 __glibcxx_requires_valid_range(__first, __last);
3392 __glibcxx_requires_irreflexive(__first, __last);
3394 return std::__minmax_element(__first, __last,
3395 __gnu_cxx::__ops::__iter_less_iter());
3410 template<
typename _ForwardIterator,
typename _Compare>
3411 _GLIBCXX14_CONSTEXPR
3412 inline pair<_ForwardIterator, _ForwardIterator>
3413 minmax_element(_ForwardIterator __first, _ForwardIterator __last,
3417 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3418 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
3421 __glibcxx_requires_valid_range(__first, __last);
3422 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
3424 return std::__minmax_element(__first, __last,
3425 __gnu_cxx::__ops::__iter_comp_iter(__comp));
3428 template<
typename _Tp>
3429 _GLIBCXX14_CONSTEXPR
3430 inline pair<_Tp, _Tp>
3431 minmax(initializer_list<_Tp> __l)
3433 __glibcxx_requires_irreflexive(__l.begin(), __l.end());
3434 pair<const _Tp*, const _Tp*> __p =
3435 std::__minmax_element(__l.begin(), __l.end(),
3436 __gnu_cxx::__ops::__iter_less_iter());
3437 return std::make_pair(*__p.first, *__p.second);
3440 template<
typename _Tp,
typename _Compare>
3441 _GLIBCXX14_CONSTEXPR
3442 inline pair<_Tp, _Tp>
3443 minmax(initializer_list<_Tp> __l, _Compare __comp)
3445 __glibcxx_requires_irreflexive_pred(__l.begin(), __l.end(), __comp);
3446 pair<const _Tp*, const _Tp*> __p =
3447 std::__minmax_element(__l.begin(), __l.end(),
3448 __gnu_cxx::__ops::__iter_comp_iter(__comp));
3449 return std::make_pair(*__p.first, *__p.second);
3466 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
3467 typename _BinaryPredicate>
3468 _GLIBCXX20_CONSTEXPR
3470 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
3471 _ForwardIterator2 __first2, _BinaryPredicate __pred)
3474 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
3475 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
3476 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
3479 __glibcxx_requires_valid_range(__first1, __last1);
3481 return std::__is_permutation(__first1, __last1, __first2,
3482 __gnu_cxx::__ops::__iter_comp_iter(__pred));
3485#if __cplusplus > 201103L
3486 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
3487 typename _BinaryPredicate>
3488 _GLIBCXX20_CONSTEXPR
3490 __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
3491 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
3492 _BinaryPredicate __pred)
3495 =
typename iterator_traits<_ForwardIterator1>::iterator_category;
3497 =
typename iterator_traits<_ForwardIterator2>::iterator_category;
3498 using _It1_is_RA = is_same<_Cat1, random_access_iterator_tag>;
3499 using _It2_is_RA = is_same<_Cat2, random_access_iterator_tag>;
3500 constexpr bool __ra_iters = _It1_is_RA() && _It2_is_RA();
3511 for (; __first1 != __last1 && __first2 != __last2;
3512 ++__first1, (void)++__first2)
3513 if (!__pred(__first1, __first2))
3518 if (__first1 == __last1)
3525 if (__d1 == 0 && __d2 == 0)
3531 for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan)
3534 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)))
3537 auto __matches = std::__count_if(__first2, __last2,
3538 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan));
3540 || std::__count_if(__scan, __last1,
3541 __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))
3561 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
3562 _GLIBCXX20_CONSTEXPR
3564 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
3565 _ForwardIterator2 __first2, _ForwardIterator2 __last2)
3567 __glibcxx_requires_valid_range(__first1, __last1);
3568 __glibcxx_requires_valid_range(__first2, __last2);
3571 std::__is_permutation(__first1, __last1, __first2, __last2,
3572 __gnu_cxx::__ops::__iter_equal_to_iter());
3589 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
3590 typename _BinaryPredicate>
3591 _GLIBCXX20_CONSTEXPR
3593 is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
3594 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
3595 _BinaryPredicate __pred)
3597 __glibcxx_requires_valid_range(__first1, __last1);
3598 __glibcxx_requires_valid_range(__first2, __last2);
3600 return std::__is_permutation(__first1, __last1, __first2, __last2,
3601 __gnu_cxx::__ops::__iter_comp_iter(__pred));
3604#if __cplusplus >= 201703L
3606#define __cpp_lib_clamp 201603L
3619 template<
typename _Tp>
3620 constexpr const _Tp&
3621 clamp(
const _Tp& __val,
const _Tp& __lo,
const _Tp& __hi)
3623 __glibcxx_assert(!(__hi < __lo));
3639 template<
typename _Tp,
typename _Compare>
3640 constexpr const _Tp&
3641 clamp(
const _Tp& __val,
const _Tp& __lo,
const _Tp& __hi, _Compare __comp)
3643 __glibcxx_assert(!__comp(__hi, __lo));
3649#ifdef _GLIBCXX_USE_C99_STDINT_TR1
3671 template<
typename _IntType,
typename _UniformRandomBitGenerator>
3672 pair<_IntType, _IntType>
3674 _UniformRandomBitGenerator&& __g)
3678 return std::make_pair(__x / __b1, __x % __b1);
3693 template<
typename _RandomAccessIterator,
3694 typename _UniformRandomNumberGenerator>
3696 shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
3697 _UniformRandomNumberGenerator&& __g)
3700 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
3701 _RandomAccessIterator>)
3702 __glibcxx_requires_valid_range(__first, __last);
3704 if (__first == __last)
3710 typedef typename std::make_unsigned<_DistanceType>::type __ud_type;
3712 typedef typename __distr_type::param_type __p_type;
3714 typedef typename remove_reference<_UniformRandomNumberGenerator>::type
3719 const __uc_type __urngrange = __g.max() - __g.min();
3720 const __uc_type __urange = __uc_type(__last - __first);
3722 if (__urngrange / __urange >= __urange)
3725 _RandomAccessIterator __i = __first + 1;
3731 if ((__urange % 2) == 0)
3733 __distr_type __d{0, 1};
3734 std::iter_swap(__i++, __first + __d(__g));
3741 while (__i != __last)
3743 const __uc_type __swap_range = __uc_type(__i - __first) + 1;
3748 std::iter_swap(__i++, __first + __pospos.
first);
3749 std::iter_swap(__i++, __first + __pospos.
second);
3757 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
3758 std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first)));
3764_GLIBCXX_BEGIN_NAMESPACE_ALGO
3778 template<
typename _InputIterator,
typename _Function>
3779 _GLIBCXX20_CONSTEXPR
3781 for_each(_InputIterator __first, _InputIterator __last, _Function __f)
3784 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3785 __glibcxx_requires_valid_range(__first, __last);
3786 for (; __first != __last; ++__first)
3791#if __cplusplus >= 201703L
3804 template<
typename _InputIterator,
typename _Size,
typename _Function>
3805 _GLIBCXX20_CONSTEXPR
3809 auto __n2 = std::__size_to_integer(__n);
3811 if constexpr (is_base_of_v<random_access_iterator_tag, _Cat>)
3815 auto __last = __first + __n2;
3816 std::for_each(__first, __last,
std::move(__f));
3840 template<
typename _InputIterator,
typename _Tp>
3841 _GLIBCXX20_CONSTEXPR
3842 inline _InputIterator
3843 find(_InputIterator __first, _InputIterator __last,
3847 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3848 __glibcxx_function_requires(_EqualOpConcept<
3850 __glibcxx_requires_valid_range(__first, __last);
3852 __gnu_cxx::__ops::__iter_equals_val(__val));
3865 template<
typename _InputIterator,
typename _Predicate>
3866 _GLIBCXX20_CONSTEXPR
3867 inline _InputIterator
3868 find_if(_InputIterator __first, _InputIterator __last,
3872 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3873 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
3875 __glibcxx_requires_valid_range(__first, __last);
3878 __gnu_cxx::__ops::__pred_iter(__pred));
3897 template<
typename _InputIterator,
typename _ForwardIterator>
3898 _GLIBCXX20_CONSTEXPR
3900 find_first_of(_InputIterator __first1, _InputIterator __last1,
3901 _ForwardIterator __first2, _ForwardIterator __last2)
3904 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3905 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3906 __glibcxx_function_requires(_EqualOpConcept<
3909 __glibcxx_requires_valid_range(__first1, __last1);
3910 __glibcxx_requires_valid_range(__first2, __last2);
3912 for (; __first1 != __last1; ++__first1)
3913 for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
3914 if (*__first1 == *__iter)
3938 template<
typename _InputIterator,
typename _ForwardIterator,
3939 typename _BinaryPredicate>
3940 _GLIBCXX20_CONSTEXPR
3942 find_first_of(_InputIterator __first1, _InputIterator __last1,
3943 _ForwardIterator __first2, _ForwardIterator __last2,
3944 _BinaryPredicate __comp)
3947 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
3948 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3949 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
3952 __glibcxx_requires_valid_range(__first1, __last1);
3953 __glibcxx_requires_valid_range(__first2, __last2);
3955 for (; __first1 != __last1; ++__first1)
3956 for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter)
3957 if (__comp(*__first1, *__iter))
3971 template<
typename _ForwardIterator>
3972 _GLIBCXX20_CONSTEXPR
3973 inline _ForwardIterator
3974 adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
3977 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3978 __glibcxx_function_requires(_EqualityComparableConcept<
3980 __glibcxx_requires_valid_range(__first, __last);
3982 return std::__adjacent_find(__first, __last,
3983 __gnu_cxx::__ops::__iter_equal_to_iter());
3997 template<
typename _ForwardIterator,
typename _BinaryPredicate>
3998 _GLIBCXX20_CONSTEXPR
3999 inline _ForwardIterator
4000 adjacent_find(_ForwardIterator __first, _ForwardIterator __last,
4001 _BinaryPredicate __binary_pred)
4004 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4005 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4008 __glibcxx_requires_valid_range(__first, __last);
4010 return std::__adjacent_find(__first, __last,
4011 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
4023 template<
typename _InputIterator,
typename _Tp>
4024 _GLIBCXX20_CONSTEXPR
4025 inline typename iterator_traits<_InputIterator>::difference_type
4026 count(_InputIterator __first, _InputIterator __last,
const _Tp& __value)
4029 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4030 __glibcxx_function_requires(_EqualOpConcept<
4032 __glibcxx_requires_valid_range(__first, __last);
4034 return std::__count_if(__first, __last,
4035 __gnu_cxx::__ops::__iter_equals_val(__value));
4047 template<
typename _InputIterator,
typename _Predicate>
4048 _GLIBCXX20_CONSTEXPR
4049 inline typename iterator_traits<_InputIterator>::difference_type
4050 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
4053 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4054 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
4056 __glibcxx_requires_valid_range(__first, __last);
4058 return std::__count_if(__first, __last,
4059 __gnu_cxx::__ops::__pred_iter(__pred));
4088 template<
typename _ForwardIterator1,
typename _ForwardIterator2>
4089 _GLIBCXX20_CONSTEXPR
4090 inline _ForwardIterator1
4091 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
4092 _ForwardIterator2 __first2, _ForwardIterator2 __last2)
4095 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
4096 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
4097 __glibcxx_function_requires(_EqualOpConcept<
4100 __glibcxx_requires_valid_range(__first1, __last1);
4101 __glibcxx_requires_valid_range(__first2, __last2);
4103 return std::__search(__first1, __last1, __first2, __last2,
4104 __gnu_cxx::__ops::__iter_equal_to_iter());
4128 template<
typename _ForwardIterator1,
typename _ForwardIterator2,
4129 typename _BinaryPredicate>
4130 _GLIBCXX20_CONSTEXPR
4131 inline _ForwardIterator1
4132 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
4133 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
4134 _BinaryPredicate __predicate)
4137 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
4138 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
4139 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4142 __glibcxx_requires_valid_range(__first1, __last1);
4143 __glibcxx_requires_valid_range(__first2, __last2);
4145 return std::__search(__first1, __last1, __first2, __last2,
4146 __gnu_cxx::__ops::__iter_comp_iter(__predicate));
4164 template<
typename _ForwardIterator,
typename _Integer,
typename _Tp>
4165 _GLIBCXX20_CONSTEXPR
4166 inline _ForwardIterator
4167 search_n(_ForwardIterator __first, _ForwardIterator __last,
4168 _Integer __count,
const _Tp& __val)
4171 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4172 __glibcxx_function_requires(_EqualOpConcept<
4174 __glibcxx_requires_valid_range(__first, __last);
4176 return std::__search_n(__first, __last, __count,
4177 __gnu_cxx::__ops::__iter_equals_val(__val));
4198 template<
typename _ForwardIterator,
typename _Integer,
typename _Tp,
4199 typename _BinaryPredicate>
4200 _GLIBCXX20_CONSTEXPR
4201 inline _ForwardIterator
4202 search_n(_ForwardIterator __first, _ForwardIterator __last,
4203 _Integer __count,
const _Tp& __val,
4204 _BinaryPredicate __binary_pred)
4207 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4208 __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
4210 __glibcxx_requires_valid_range(__first, __last);
4212 return std::__search_n(__first, __last, __count,
4213 __gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val));
4216#if __cplusplus >= 201703L
4224 template<
typename _ForwardIterator,
typename _Searcher>
4225 _GLIBCXX20_CONSTEXPR
4226 inline _ForwardIterator
4227 search(_ForwardIterator __first, _ForwardIterator __last,
4228 const _Searcher& __searcher)
4229 {
return __searcher(__first, __last).first; }
4248 template<
typename _InputIterator,
typename _OutputIterator,
4249 typename _UnaryOperation>
4250 _GLIBCXX20_CONSTEXPR
4252 transform(_InputIterator __first, _InputIterator __last,
4253 _OutputIterator __result, _UnaryOperation __unary_op)
4256 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4257 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4259 __typeof__(__unary_op(*__first))>)
4260 __glibcxx_requires_valid_range(__first, __last);
4262 for (; __first != __last; ++__first, (void)++__result)
4263 *__result = __unary_op(*__first);
4286 template<
typename _InputIterator1,
typename _InputIterator2,
4287 typename _OutputIterator,
typename _BinaryOperation>
4288 _GLIBCXX20_CONSTEXPR
4290 transform(_InputIterator1 __first1, _InputIterator1 __last1,
4291 _InputIterator2 __first2, _OutputIterator __result,
4292 _BinaryOperation __binary_op)
4295 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
4296 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
4297 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4299 __typeof__(__binary_op(*__first1,*__first2))>)
4300 __glibcxx_requires_valid_range(__first1, __last1);
4302 for (; __first1 != __last1; ++__first1, (void)++__first2, ++__result)
4303 *__result = __binary_op(*__first1, *__first2);
4320 template<
typename _ForwardIterator,
typename _Tp>
4321 _GLIBCXX20_CONSTEXPR
4323 replace(_ForwardIterator __first, _ForwardIterator __last,
4324 const _Tp& __old_value,
const _Tp& __new_value)
4327 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
4329 __glibcxx_function_requires(_EqualOpConcept<
4331 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
4333 __glibcxx_requires_valid_range(__first, __last);
4335 for (; __first != __last; ++__first)
4336 if (*__first == __old_value)
4337 *__first = __new_value;
4353 template<
typename _ForwardIterator,
typename _Predicate,
typename _Tp>
4354 _GLIBCXX20_CONSTEXPR
4356 replace_if(_ForwardIterator __first, _ForwardIterator __last,
4357 _Predicate __pred,
const _Tp& __new_value)
4360 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
4362 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
4364 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
4366 __glibcxx_requires_valid_range(__first, __last);
4368 for (; __first != __last; ++__first)
4369 if (__pred(*__first))
4370 *__first = __new_value;
4386 template<
typename _ForwardIterator,
typename _Generator>
4387 _GLIBCXX20_CONSTEXPR
4389 generate(_ForwardIterator __first, _ForwardIterator __last,
4393 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
4394 __glibcxx_function_requires(_GeneratorConcept<_Generator,
4396 __glibcxx_requires_valid_range(__first, __last);
4398 for (; __first != __last; ++__first)
4420 template<
typename _OutputIterator,
typename _Size,
typename _Generator>
4421 _GLIBCXX20_CONSTEXPR
4423 generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
4426 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4428 __typeof__(__gen())>)
4430 typedef __decltype(std::__size_to_integer(__n)) _IntSize;
4431 for (_IntSize __niter = std::__size_to_integer(__n);
4432 __niter > 0; --__niter, (void) ++__first)
4458 template<
typename _InputIterator,
typename _OutputIterator>
4459 _GLIBCXX20_CONSTEXPR
4460 inline _OutputIterator
4461 unique_copy(_InputIterator __first, _InputIterator __last,
4462 _OutputIterator __result)
4465 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4466 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4468 __glibcxx_function_requires(_EqualityComparableConcept<
4470 __glibcxx_requires_valid_range(__first, __last);
4472 if (__first == __last)
4475 __gnu_cxx::__ops::__iter_equal_to_iter(),
4499 template<
typename _InputIterator,
typename _OutputIterator,
4500 typename _BinaryPredicate>
4501 _GLIBCXX20_CONSTEXPR
4502 inline _OutputIterator
4503 unique_copy(_InputIterator __first, _InputIterator __last,
4504 _OutputIterator __result,
4505 _BinaryPredicate __binary_pred)
4508 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
4509 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4511 __glibcxx_requires_valid_range(__first, __last);
4513 if (__first == __last)
4516 __gnu_cxx::__ops::__iter_comp_iter(__binary_pred),
4521#if __cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED
4538 template<
typename _RandomAccessIterator>
4539 _GLIBCXX14_DEPRECATED_SUGGEST(
"std::shuffle")
4541 random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
4544 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4545 _RandomAccessIterator>)
4546 __glibcxx_requires_valid_range(__first, __last);
4548 if (__first != __last)
4549 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
4552 _RandomAccessIterator __j = __first
4553 + std::rand() % ((__i - __first) + 1);
4555 std::iter_swap(__i, __j);
4578 template<
typename _RandomAccessIterator,
typename _RandomNumberGenerator>
4579 _GLIBCXX14_DEPRECATED_SUGGEST(
"std::shuffle")
4581 random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
4582#if __cplusplus >= 201103L
4583 _RandomNumberGenerator&& __rand)
4585 _RandomNumberGenerator& __rand)
4589 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4590 _RandomAccessIterator>)
4591 __glibcxx_requires_valid_range(__first, __last);
4593 if (__first == __last)
4595 for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i)
4597 _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
4599 std::iter_swap(__i, __j);
4619 template<
typename _ForwardIterator,
typename _Predicate>
4620 _GLIBCXX20_CONSTEXPR
4621 inline _ForwardIterator
4622 partition(_ForwardIterator __first, _ForwardIterator __last,
4626 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
4628 __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
4630 __glibcxx_requires_valid_range(__first, __last);
4653 template<
typename _RandomAccessIterator>
4654 _GLIBCXX20_CONSTEXPR
4656 partial_sort(_RandomAccessIterator __first,
4657 _RandomAccessIterator __middle,
4658 _RandomAccessIterator __last)
4661 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4662 _RandomAccessIterator>)
4663 __glibcxx_function_requires(_LessThanComparableConcept<
4665 __glibcxx_requires_valid_range(__first, __middle);
4666 __glibcxx_requires_valid_range(__middle, __last);
4667 __glibcxx_requires_irreflexive(__first, __last);
4669 std::__partial_sort(__first, __middle, __last,
4670 __gnu_cxx::__ops::__iter_less_iter());
4692 template<
typename _RandomAccessIterator,
typename _Compare>
4693 _GLIBCXX20_CONSTEXPR
4695 partial_sort(_RandomAccessIterator __first,
4696 _RandomAccessIterator __middle,
4697 _RandomAccessIterator __last,
4701 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4702 _RandomAccessIterator>)
4703 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
4706 __glibcxx_requires_valid_range(__first, __middle);
4707 __glibcxx_requires_valid_range(__middle, __last);
4708 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
4710 std::__partial_sort(__first, __middle, __last,
4711 __gnu_cxx::__ops::__iter_comp_iter(__comp));
4729 template<
typename _RandomAccessIterator>
4730 _GLIBCXX20_CONSTEXPR
4732 nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
4733 _RandomAccessIterator __last)
4736 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4737 _RandomAccessIterator>)
4738 __glibcxx_function_requires(_LessThanComparableConcept<
4740 __glibcxx_requires_valid_range(__first, __nth);
4741 __glibcxx_requires_valid_range(__nth, __last);
4742 __glibcxx_requires_irreflexive(__first, __last);
4744 if (__first == __last || __nth == __last)
4747 std::__introselect(__first, __nth, __last,
4749 __gnu_cxx::__ops::__iter_less_iter());
4769 template<
typename _RandomAccessIterator,
typename _Compare>
4770 _GLIBCXX20_CONSTEXPR
4772 nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth,
4773 _RandomAccessIterator __last, _Compare __comp)
4776 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4777 _RandomAccessIterator>)
4778 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
4781 __glibcxx_requires_valid_range(__first, __nth);
4782 __glibcxx_requires_valid_range(__nth, __last);
4783 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
4785 if (__first == __last || __nth == __last)
4788 std::__introselect(__first, __nth, __last,
4790 __gnu_cxx::__ops::__iter_comp_iter(__comp));
4807 template<
typename _RandomAccessIterator>
4808 _GLIBCXX20_CONSTEXPR
4810 sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
4813 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4814 _RandomAccessIterator>)
4815 __glibcxx_function_requires(_LessThanComparableConcept<
4817 __glibcxx_requires_valid_range(__first, __last);
4818 __glibcxx_requires_irreflexive(__first, __last);
4820 std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
4838 template<
typename _RandomAccessIterator,
typename _Compare>
4839 _GLIBCXX20_CONSTEXPR
4841 sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
4845 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
4846 _RandomAccessIterator>)
4847 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
4850 __glibcxx_requires_valid_range(__first, __last);
4851 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
4853 std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
4856 template<
typename _InputIterator1,
typename _InputIterator2,
4857 typename _OutputIterator,
typename _Compare>
4858 _GLIBCXX20_CONSTEXPR
4860 __merge(_InputIterator1 __first1, _InputIterator1 __last1,
4861 _InputIterator2 __first2, _InputIterator2 __last2,
4862 _OutputIterator __result, _Compare __comp)
4864 while (__first1 != __last1 && __first2 != __last2)
4866 if (__comp(__first2, __first1))
4868 *__result = *__first2;
4873 *__result = *__first1;
4878 return std::copy(__first2, __last2,
4879 std::copy(__first1, __last1, __result));
4901 template<
typename _InputIterator1,
typename _InputIterator2,
4902 typename _OutputIterator>
4903 _GLIBCXX20_CONSTEXPR
4904 inline _OutputIterator
4905 merge(_InputIterator1 __first1, _InputIterator1 __last1,
4906 _InputIterator2 __first2, _InputIterator2 __last2,
4907 _OutputIterator __result)
4910 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
4911 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
4912 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4914 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4916 __glibcxx_function_requires(_LessThanOpConcept<
4919 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
4920 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
4921 __glibcxx_requires_irreflexive2(__first1, __last1);
4922 __glibcxx_requires_irreflexive2(__first2, __last2);
4924 return _GLIBCXX_STD_A::__merge(__first1, __last1,
4925 __first2, __last2, __result,
4926 __gnu_cxx::__ops::__iter_less_iter());
4952 template<
typename _InputIterator1,
typename _InputIterator2,
4953 typename _OutputIterator,
typename _Compare>
4954 _GLIBCXX20_CONSTEXPR
4955 inline _OutputIterator
4956 merge(_InputIterator1 __first1, _InputIterator1 __last1,
4957 _InputIterator2 __first2, _InputIterator2 __last2,
4958 _OutputIterator __result, _Compare __comp)
4961 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
4962 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
4963 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4965 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
4967 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
4970 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
4971 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
4972 __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
4973 __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
4975 return _GLIBCXX_STD_A::__merge(__first1, __last1,
4976 __first2, __last2, __result,
4977 __gnu_cxx::__ops::__iter_comp_iter(__comp));
4980 template<
typename _RandomAccessIterator,
typename _Compare>
4982 __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
4985 typedef typename iterator_traits<_RandomAccessIterator>::value_type
4987 typedef typename iterator_traits<_RandomAccessIterator>::difference_type
4989 typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf;
4991 if (__first == __last)
4996 _TmpBuf __buf(__first, (__last - __first + 1) / 2);
4998 if (__buf.begin() == 0)
5001 std::__stable_sort_adaptive(__first, __last, __buf.begin(),
5002 _DistanceType(__buf.size()), __comp);
5022 template<
typename _RandomAccessIterator>
5024 stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
5027 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5028 _RandomAccessIterator>)
5029 __glibcxx_function_requires(_LessThanComparableConcept<
5031 __glibcxx_requires_valid_range(__first, __last);
5032 __glibcxx_requires_irreflexive(__first, __last);
5034 _GLIBCXX_STD_A::__stable_sort(__first, __last,
5035 __gnu_cxx::__ops::__iter_less_iter());
5056 template<
typename _RandomAccessIterator,
typename _Compare>
5058 stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
5062 __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
5063 _RandomAccessIterator>)
5064 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5067 __glibcxx_requires_valid_range(__first, __last);
5068 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
5070 _GLIBCXX_STD_A::__stable_sort(__first, __last,
5071 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5074 template<
typename _InputIterator1,
typename _InputIterator2,
5075 typename _OutputIterator,
5077 _GLIBCXX20_CONSTEXPR
5079 __set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5080 _InputIterator2 __first2, _InputIterator2 __last2,
5081 _OutputIterator __result, _Compare __comp)
5083 while (__first1 != __last1 && __first2 != __last2)
5085 if (__comp(__first1, __first2))
5087 *__result = *__first1;
5090 else if (__comp(__first2, __first1))
5092 *__result = *__first2;
5097 *__result = *__first1;
5103 return std::copy(__first2, __last2,
5104 std::copy(__first1, __last1, __result));
5126 template<
typename _InputIterator1,
typename _InputIterator2,
5127 typename _OutputIterator>
5128 _GLIBCXX20_CONSTEXPR
5129 inline _OutputIterator
5130 set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5131 _InputIterator2 __first2, _InputIterator2 __last2,
5132 _OutputIterator __result)
5135 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5136 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5137 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5139 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5141 __glibcxx_function_requires(_LessThanOpConcept<
5144 __glibcxx_function_requires(_LessThanOpConcept<
5147 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5148 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5149 __glibcxx_requires_irreflexive2(__first1, __last1);
5150 __glibcxx_requires_irreflexive2(__first2, __last2);
5152 return _GLIBCXX_STD_A::__set_union(__first1, __last1,
5153 __first2, __last2, __result,
5154 __gnu_cxx::__ops::__iter_less_iter());
5177 template<
typename _InputIterator1,
typename _InputIterator2,
5178 typename _OutputIterator,
typename _Compare>
5179 _GLIBCXX20_CONSTEXPR
5180 inline _OutputIterator
5181 set_union(_InputIterator1 __first1, _InputIterator1 __last1,
5182 _InputIterator2 __first2, _InputIterator2 __last2,
5183 _OutputIterator __result, _Compare __comp)
5186 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5187 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5188 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5190 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5192 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5195 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5198 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5199 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5200 __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
5201 __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
5203 return _GLIBCXX_STD_A::__set_union(__first1, __last1,
5204 __first2, __last2, __result,
5205 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5208 template<
typename _InputIterator1,
typename _InputIterator2,
5209 typename _OutputIterator,
5211 _GLIBCXX20_CONSTEXPR
5213 __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5214 _InputIterator2 __first2, _InputIterator2 __last2,
5215 _OutputIterator __result, _Compare __comp)
5217 while (__first1 != __last1 && __first2 != __last2)
5218 if (__comp(__first1, __first2))
5220 else if (__comp(__first2, __first1))
5224 *__result = *__first1;
5250 template<
typename _InputIterator1,
typename _InputIterator2,
5251 typename _OutputIterator>
5252 _GLIBCXX20_CONSTEXPR
5253 inline _OutputIterator
5254 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5255 _InputIterator2 __first2, _InputIterator2 __last2,
5256 _OutputIterator __result)
5259 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5260 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5261 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5263 __glibcxx_function_requires(_LessThanOpConcept<
5266 __glibcxx_function_requires(_LessThanOpConcept<
5269 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5270 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5271 __glibcxx_requires_irreflexive2(__first1, __last1);
5272 __glibcxx_requires_irreflexive2(__first2, __last2);
5274 return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
5275 __first2, __last2, __result,
5276 __gnu_cxx::__ops::__iter_less_iter());
5300 template<
typename _InputIterator1,
typename _InputIterator2,
5301 typename _OutputIterator,
typename _Compare>
5302 _GLIBCXX20_CONSTEXPR
5303 inline _OutputIterator
5304 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
5305 _InputIterator2 __first2, _InputIterator2 __last2,
5306 _OutputIterator __result, _Compare __comp)
5309 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5310 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5311 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5313 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5316 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5319 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5320 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5321 __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
5322 __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
5324 return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
5325 __first2, __last2, __result,
5326 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5329 template<
typename _InputIterator1,
typename _InputIterator2,
5330 typename _OutputIterator,
5332 _GLIBCXX20_CONSTEXPR
5334 __set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5335 _InputIterator2 __first2, _InputIterator2 __last2,
5336 _OutputIterator __result, _Compare __comp)
5338 while (__first1 != __last1 && __first2 != __last2)
5339 if (__comp(__first1, __first2))
5341 *__result = *__first1;
5345 else if (__comp(__first2, __first1))
5352 return std::copy(__first1, __last1, __result);
5375 template<
typename _InputIterator1,
typename _InputIterator2,
5376 typename _OutputIterator>
5377 _GLIBCXX20_CONSTEXPR
5378 inline _OutputIterator
5379 set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5380 _InputIterator2 __first2, _InputIterator2 __last2,
5381 _OutputIterator __result)
5384 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5385 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5386 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5388 __glibcxx_function_requires(_LessThanOpConcept<
5391 __glibcxx_function_requires(_LessThanOpConcept<
5394 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5395 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5396 __glibcxx_requires_irreflexive2(__first1, __last1);
5397 __glibcxx_requires_irreflexive2(__first2, __last2);
5399 return _GLIBCXX_STD_A::__set_difference(__first1, __last1,
5400 __first2, __last2, __result,
5401 __gnu_cxx::__ops::__iter_less_iter());
5427 template<
typename _InputIterator1,
typename _InputIterator2,
5428 typename _OutputIterator,
typename _Compare>
5429 _GLIBCXX20_CONSTEXPR
5430 inline _OutputIterator
5431 set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5432 _InputIterator2 __first2, _InputIterator2 __last2,
5433 _OutputIterator __result, _Compare __comp)
5436 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5437 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5438 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5440 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5443 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5446 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5447 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5448 __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
5449 __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
5451 return _GLIBCXX_STD_A::__set_difference(__first1, __last1,
5452 __first2, __last2, __result,
5453 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5456 template<
typename _InputIterator1,
typename _InputIterator2,
5457 typename _OutputIterator,
5459 _GLIBCXX20_CONSTEXPR
5461 __set_symmetric_difference(_InputIterator1 __first1,
5462 _InputIterator1 __last1,
5463 _InputIterator2 __first2,
5464 _InputIterator2 __last2,
5465 _OutputIterator __result,
5468 while (__first1 != __last1 && __first2 != __last2)
5469 if (__comp(__first1, __first2))
5471 *__result = *__first1;
5475 else if (__comp(__first2, __first1))
5477 *__result = *__first2;
5486 return std::copy(__first2, __last2,
5487 std::copy(__first1, __last1, __result));
5508 template<
typename _InputIterator1,
typename _InputIterator2,
5509 typename _OutputIterator>
5510 _GLIBCXX20_CONSTEXPR
5511 inline _OutputIterator
5512 set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5513 _InputIterator2 __first2, _InputIterator2 __last2,
5514 _OutputIterator __result)
5517 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5518 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5519 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5521 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5523 __glibcxx_function_requires(_LessThanOpConcept<
5526 __glibcxx_function_requires(_LessThanOpConcept<
5529 __glibcxx_requires_sorted_set(__first1, __last1, __first2);
5530 __glibcxx_requires_sorted_set(__first2, __last2, __first1);
5531 __glibcxx_requires_irreflexive2(__first1, __last1);
5532 __glibcxx_requires_irreflexive2(__first2, __last2);
5534 return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1,
5535 __first2, __last2, __result,
5536 __gnu_cxx::__ops::__iter_less_iter());
5560 template<
typename _InputIterator1,
typename _InputIterator2,
5561 typename _OutputIterator,
typename _Compare>
5562 _GLIBCXX20_CONSTEXPR
5563 inline _OutputIterator
5564 set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
5565 _InputIterator2 __first2, _InputIterator2 __last2,
5566 _OutputIterator __result,
5570 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
5571 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
5572 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5574 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
5576 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5579 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5582 __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp);
5583 __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp);
5584 __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp);
5585 __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp);
5587 return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1,
5588 __first2, __last2, __result,
5589 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5592 template<
typename _ForwardIterator,
typename _Compare>
5593 _GLIBCXX14_CONSTEXPR
5595 __min_element(_ForwardIterator __first, _ForwardIterator __last,
5598 if (__first == __last)
5600 _ForwardIterator __result = __first;
5601 while (++__first != __last)
5602 if (__comp(__first, __result))
5614 template<
typename _ForwardIterator>
5615 _GLIBCXX14_CONSTEXPR
5617 inline min_element(_ForwardIterator __first, _ForwardIterator __last)
5620 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
5621 __glibcxx_function_requires(_LessThanComparableConcept<
5623 __glibcxx_requires_valid_range(__first, __last);
5624 __glibcxx_requires_irreflexive(__first, __last);
5626 return _GLIBCXX_STD_A::__min_element(__first, __last,
5627 __gnu_cxx::__ops::__iter_less_iter());
5639 template<
typename _ForwardIterator,
typename _Compare>
5640 _GLIBCXX14_CONSTEXPR
5641 inline _ForwardIterator
5642 min_element(_ForwardIterator __first, _ForwardIterator __last,
5646 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
5647 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5650 __glibcxx_requires_valid_range(__first, __last);
5651 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
5653 return _GLIBCXX_STD_A::__min_element(__first, __last,
5654 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5657 template<
typename _ForwardIterator,
typename _Compare>
5658 _GLIBCXX14_CONSTEXPR
5660 __max_element(_ForwardIterator __first, _ForwardIterator __last,
5663 if (__first == __last)
return __first;
5664 _ForwardIterator __result = __first;
5665 while (++__first != __last)
5666 if (__comp(__result, __first))
5678 template<
typename _ForwardIterator>
5679 _GLIBCXX14_CONSTEXPR
5680 inline _ForwardIterator
5681 max_element(_ForwardIterator __first, _ForwardIterator __last)
5684 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
5685 __glibcxx_function_requires(_LessThanComparableConcept<
5687 __glibcxx_requires_valid_range(__first, __last);
5688 __glibcxx_requires_irreflexive(__first, __last);
5690 return _GLIBCXX_STD_A::__max_element(__first, __last,
5691 __gnu_cxx::__ops::__iter_less_iter());
5703 template<
typename _ForwardIterator,
typename _Compare>
5704 _GLIBCXX14_CONSTEXPR
5705 inline _ForwardIterator
5706 max_element(_ForwardIterator __first, _ForwardIterator __last,
5710 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
5711 __glibcxx_function_requires(_BinaryPredicateConcept<_Compare,
5714 __glibcxx_requires_valid_range(__first, __last);
5715 __glibcxx_requires_irreflexive_pred(__first, __last, __comp);
5717 return _GLIBCXX_STD_A::__max_element(__first, __last,
5718 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5721#if __cplusplus >= 201103L
5723 template<
typename _Tp>
5724 _GLIBCXX14_CONSTEXPR
5726 min(initializer_list<_Tp> __l)
5728 __glibcxx_requires_irreflexive(__l.begin(), __l.end());
5729 return *_GLIBCXX_STD_A::__min_element(__l.begin(), __l.end(),
5730 __gnu_cxx::__ops::__iter_less_iter());
5733 template<
typename _Tp,
typename _Compare>
5734 _GLIBCXX14_CONSTEXPR
5736 min(initializer_list<_Tp> __l, _Compare __comp)
5738 __glibcxx_requires_irreflexive_pred(__l.begin(), __l.end(), __comp);
5739 return *_GLIBCXX_STD_A::__min_element(__l.begin(), __l.end(),
5740 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5743 template<
typename _Tp>
5744 _GLIBCXX14_CONSTEXPR
5746 max(initializer_list<_Tp> __l)
5748 __glibcxx_requires_irreflexive(__l.begin(), __l.end());
5749 return *_GLIBCXX_STD_A::__max_element(__l.begin(), __l.end(),
5750 __gnu_cxx::__ops::__iter_less_iter());
5753 template<
typename _Tp,
typename _Compare>
5754 _GLIBCXX14_CONSTEXPR
5756 max(initializer_list<_Tp> __l, _Compare __comp)
5758 __glibcxx_requires_irreflexive_pred(__l.begin(), __l.end(), __comp);
5759 return *_GLIBCXX_STD_A::__max_element(__l.begin(), __l.end(),
5760 __gnu_cxx::__ops::__iter_comp_iter(__comp));
5764#if __cplusplus >= 201402L
5766 template<
typename _InputIterator,
typename _RandomAccessIterator,
5767 typename _Size,
typename _UniformRandomBitGenerator>
5768 _RandomAccessIterator
5771 _Size __n, _UniformRandomBitGenerator&& __g)
5774 using __param_type =
typename __distrib_type::param_type;
5775 __distrib_type __d{};
5776 _Size __sample_sz = 0;
5777 while (__first != __last && __sample_sz != __n)
5779 __out[__sample_sz++] = *__first;
5782 for (
auto __pop_sz = __sample_sz; __first != __last;
5783 ++__first, (void) ++__pop_sz)
5785 const auto __k = __d(__g, __param_type{0, __pop_sz});
5787 __out[__k] = *__first;
5789 return __out + __sample_sz;
5793 template<
typename _ForwardIterator,
typename _OutputIterator,
typename _Cat,
5794 typename _Size,
typename _UniformRandomBitGenerator>
5796 __sample(_ForwardIterator __first, _ForwardIterator __last,
5798 _OutputIterator __out, _Cat,
5799 _Size __n, _UniformRandomBitGenerator&& __g)
5802 using __param_type =
typename __distrib_type::param_type;
5807 if (__first == __last)
5810 __distrib_type __d{};
5812 __n =
std::min(__n, __unsampled_sz);
5817 const __uc_type __urngrange = __g.max() - __g.min();
5818 if (__urngrange / __uc_type(__unsampled_sz) >= __uc_type(__unsampled_sz))
5822 while (__n != 0 && __unsampled_sz >= 2)
5828 if (__p.
first < __n)
5830 *__out++ = *__first;
5836 if (__n == 0)
break;
5841 *__out++ = *__first;
5851 for (; __n != 0; ++__first)
5852 if (__d(__g, __param_type{0, --__unsampled_sz}) < __n)
5854 *__out++ = *__first;
5860#if __cplusplus > 201402L
5861#define __cpp_lib_sample 201603L
5863 template<
typename _PopulationIterator,
typename _SampleIterator,
5864 typename _Distance,
typename _UniformRandomBitGenerator>
5866 sample(_PopulationIterator __first, _PopulationIterator __last,
5867 _SampleIterator __out, _Distance __n,
5868 _UniformRandomBitGenerator&& __g)
5870 using __pop_cat =
typename
5872 using __samp_cat =
typename
5876 __or_<is_convertible<__pop_cat, forward_iterator_tag>,
5878 "output range must use a RandomAccessIterator when input range"
5879 " does not meet the ForwardIterator requirements");
5882 "sample size must be an integer type");
5885 return _GLIBCXX_STD_A::
5886 __sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, __d,
5887 std::forward<_UniformRandomBitGenerator>(__g));
5892_GLIBCXX_END_NAMESPACE_ALGO
5893_GLIBCXX_END_NAMESPACE_VERSION
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
typename make_unsigned< _Tp >::type make_unsigned_t
Alias template for make_unsigned.
typename common_type< _Tp... >::type common_type_t
Alias template for common_type.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _InputIterator for_each_n(_InputIterator __first, _Size __n, _Function __f)
Apply a function to every element of a sequence.
constexpr const _Tp & clamp(const _Tp &, const _Tp &, const _Tp &)
Returns the value clamped between lo and hi.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr pair< const _Tp &, const _Tp & > minmax(const _Tp &, const _Tp &)
Determines min and max at once as an ordered pair.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
_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.
_RandomAccessIterator __sample(_InputIterator __first, _InputIterator __last, input_iterator_tag, _RandomAccessIterator __out, random_access_iterator_tag, _Size __n, _UniformRandomBitGenerator &&__g)
Reservoir sampling algorithm.
constexpr _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...
constexpr void __unguarded_linear_insert(_RandomAccessIterator __last, _Compare __comp)
This is a helper function for the sort routine.
constexpr _OutputIterator __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred, forward_iterator_tag, output_iterator_tag)
void __merge_without_buffer(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Compare __comp)
This is a helper function for the merge routines.
pair< _IntType, _IntType > __gen_two_uniform_ints(_IntType __b0, _IntType __b1, _UniformRandomBitGenerator &&__g)
Generate two uniformly distributed integers using a single distribution invocation.
constexpr void __unguarded_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
This is a helper function for the sort routine.
constexpr void __heap_select(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp)
This is a helper function for the sort routines.
void __merge_adaptive(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Pointer __buffer, _Distance __buffer_size, _Compare __comp)
This is a helper function for the merge routines.
constexpr _RandomAccessIterator __unguarded_partition_pivot(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
This is a helper function...
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void __inplace_stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
This is a helper function for the stable sorting routines.
constexpr _ForwardIterator __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, forward_iterator_tag)
This is a helper function for the rotate algorithm.
constexpr void __introsort_loop(_RandomAccessIterator __first, _RandomAccessIterator __last, _Size __depth_limit, _Compare __comp)
This is a helper function for the sort routine.
constexpr _RandomAccessIterator __unguarded_partition(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomAccessIterator __pivot, _Compare __comp)
This is a helper function...
constexpr _InputIterator __find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag)
This is an overload used by find algos for the Input Iterator case.
constexpr _EuclideanRingElement __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
constexpr _ForwardIterator __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
This is a helper function...
constexpr void __insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
This is a helper function for the sort routine.
void __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
This is a helper function for the __merge_adaptive routines.
constexpr void __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
constexpr int __lg(int __n)
This is a helper function for the sort routines and for random.tcc.
_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last, _SampleIterator __out, _Distance __n, _UniformRandomBitGenerator &&__g)
Take a random sample from a population.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
constexpr void __move_median_to_first(_Iterator __result, _Iterator __a, _Iterator __b, _Iterator __c, _Compare __comp)
Swaps the median value of *__a, *__b and *__c under __comp to *__result.
constexpr _ForwardIterator __search_n_aux(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, _UnaryPredicate __unary_pred, std::forward_iterator_tag)
void __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BidirectionalIterator3 __result, _Compare __comp)
This is a helper function for the __merge_adaptive routines.
constexpr void __final_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
This is a helper function for the sort routine.
_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(__...
constexpr _InputIterator __find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
Provided for stable_partition to use.
_OutputIterator __move_merge(_InputIterator __first1, _InputIterator __last1, _InputIterator __first2, _InputIterator __last2, _OutputIterator __result, _Compare __comp)
This is a helper function for the __merge_sort_loop routines.
Traits class for iterators.
Struct holding two objects of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.
Marking output iterators.
Forward iterators support a superset of input iterator operations.
Bidirectional iterators support a superset of forward iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
Uniform discrete distribution for random numbers. A discrete random distribution on the range with e...