libstdc++
|
Modules | |
Binary Search | |
Heap | |
Set Operations | |
|
constexpr |
Returns the value clamped between lo and hi.
__val | A value of arbitrary type. |
__lo | A lower limit of arbitrary type. |
__hi | An upper limit of arbitrary type. |
`__lo` | if __val < __lo |
`__hi` | if __hi < __val |
`__val` | otherwise. |
_Tp
is LessThanComparable and (__hi < __lo)
is false. Definition at line 3627 of file stl_algo.h.
References std::max(), and std::min().
|
constexpr |
Returns the value clamped between lo and hi.
__val | A value of arbitrary type. |
__lo | A lower limit of arbitrary type. |
__hi | An upper limit of arbitrary type. |
__comp | A comparison functor. |
`__lo` | if __comp(__val, __lo) |
`__hi` | if __comp(__hi, __val) |
`__val` | otherwise. |
__comp(__hi, __lo)
is false. Definition at line 3647 of file stl_algo.h.
References std::max(), and std::min().
|
inline |
Merges two sorted ranges in place.
__first | An iterator. |
__middle | Another iterator. |
__last | Another iterator. |
Merges two sorted and consecutive ranges, [__first,__middle) and [__middle,__last), and puts the result in [__first,__last). The output will be sorted. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.
If enough additional memory is available, this takes (__last-__first)-1 comparisons. Otherwise an NlogN algorithm is used, where N is distance(__first,__last).
Definition at line 2556 of file stl_algo.h.
|
inline |
Merges two sorted ranges in place.
__first | An iterator. |
__middle | Another iterator. |
__last | Another iterator. |
__comp | A functor to use for comparisons. |
Merges two sorted and consecutive ranges, [__first,__middle) and [middle,last), and puts the result in [__first,__last). The output will be sorted. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.
If enough additional memory is available, this takes (__last-__first)-1 comparisons. Otherwise an NlogN algorithm is used, where N is distance(__first,__last).
The comparison function should have the same effects on ordering as the function used for the initial sort.
Definition at line 2597 of file stl_algo.h.
|
inlineconstexpr |
Determines whether the elements of a sequence are sorted.
__first | An iterator. |
__last | Another iterator. |
Definition at line 3193 of file stl_algo.h.
|
inlineconstexpr |
Determines whether the elements of a sequence are sorted according to a comparison functor.
__first | An iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Definition at line 3208 of file stl_algo.h.
|
inlineconstexpr |
Determines the end of a sorted sequence.
__first | An iterator. |
__last | Another iterator. |
Definition at line 3239 of file stl_algo.h.
|
inlineconstexpr |
Determines the end of a sorted sequence using comparison functor.
__first | An iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Definition at line 3264 of file stl_algo.h.
|
inlineconstexpr |
Performs dictionary comparison on ranges.
__first1 | An input iterator. |
__last1 | An input iterator. |
__first2 | An input iterator. |
__last2 | An input iterator. |
Returns true if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2). Returns false otherwise. (Quoted from [25.3.8]/1.) If the iterators are all character pointers, then this is an inline call to memcmp
.
Definition at line 1733 of file stl_algobase.h.
|
inlineconstexpr |
Performs dictionary comparison on ranges.
__first1 | An input iterator. |
__last1 | An input iterator. |
__first2 | An input iterator. |
__last2 | An input iterator. |
__comp | A comparison functor. |
The same as the four-parameter lexicographical_compare
, but uses the comp parameter instead of <
.
Definition at line 1768 of file stl_algobase.h.
|
inlineconstexpr |
This does what you think it does.
__a | A thing of arbitrary type. |
__b | Another thing of arbitrary type. |
This is the simple classic generic implementation. It will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.
Definition at line 254 of file stl_algobase.h.
Referenced by __gnu_parallel::__parallel_nth_element(), std::_Deque_base< _Tp, _Alloc >::_M_initialize_map(), std::deque< _Tp, _Alloc >::_M_reallocate_map(), std::clamp(), std::clamp(), __gnu_parallel::multiseq_partition(), __gnu_parallel::multiseq_selection(), std::shuffle_order_engine< _RandomNumberEngine, __k >::operator()(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow().
|
inlineconstexpr |
This does what you think it does.
__a | A thing of arbitrary type. |
__b | Another thing of arbitrary type. |
__comp | A comparison functor. |
This will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.
Definition at line 300 of file stl_algobase.h.
|
inlineconstexpr |
Return the maximum element in a range.
__first | Start of range. |
__last | End of range. |
Definition at line 5682 of file stl_algo.h.
|
inlineconstexpr |
Return the maximum element in a range using comparison functor.
__first | Start of range. |
__last | End of range. |
__comp | Comparison functor. |
Definition at line 5707 of file stl_algo.h.
|
inlineconstexpr |
Merges two sorted ranges.
__first1 | An iterator. |
__first2 | Another iterator. |
__last1 | Another iterator. |
__last2 | Another iterator. |
__result | An iterator pointing to the end of the merged range. |
__result
+ (__last1 - __first1)Merges the ranges [__first1,__last1) and
[__first2,__last2) into the sorted range
[__result, __result + (__last1-__first1) + (__last2-__first2)). Both input ranges must be sorted, and the output range must not overlap with either of the input ranges. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.
Definition at line 4906 of file stl_algo.h.
|
inlineconstexpr |
Merges two sorted ranges.
__first1 | An iterator. |
__first2 | Another iterator. |
__last1 | Another iterator. |
__last2 | Another iterator. |
__result | An iterator pointing to the end of the merged range. |
__comp | A functor to use for comparisons. |
__result
+ (__last1 - __first1)Merges the ranges [__first1,__last1) and
[__first2,__last2) into the sorted range
[__result, __result + (__last1-__first1) + (__last2-__first2)). Both input ranges must be sorted, and the output range must not overlap with either of the input ranges. The sort is stable, that is, for equivalent elements in the two ranges, elements from the first range will always come before elements from the second.
The comparison function should have the same effects on ordering as the function used for the initial sort.
Definition at line 4957 of file stl_algo.h.
|
inlineconstexpr |
This does what you think it does.
__a | A thing of arbitrary type. |
__b | Another thing of arbitrary type. |
This is the simple classic generic implementation. It will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.
Definition at line 230 of file stl_algobase.h.
Referenced by __gnu_parallel::__parallel_random_shuffle_drs(), __gnu_parallel::__parallel_sort_qs_divide(), std::__sample(), __gnu_parallel::__search_template(), __gnu_parallel::__sequential_random_shuffle(), std::clamp(), std::clamp(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), std::generate_canonical(), __gnu_parallel::multiseq_partition(), __gnu_parallel::multiseq_selection(), std::shuffle_order_engine< _RandomNumberEngine, __k >::operator()(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), std::basic_istream< _CharT, _Traits >::readsome(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::rfind(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), std::basic_filebuf< _CharT, encoding_char_traits< _CharT > >::seekpos(), std::basic_streambuf< _CharT, _Traits >::xsgetn(), std::basic_filebuf< _CharT, _Traits >::xsputn(), and std::basic_streambuf< _CharT, _Traits >::xsputn().
|
inlineconstexpr |
This does what you think it does.
__a | A thing of arbitrary type. |
__b | Another thing of arbitrary type. |
__comp | A comparison functor. |
This will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.
Definition at line 278 of file stl_algobase.h.
|
inlineconstexpr |
Return the minimum element in a range.
__first | Start of range. |
__last | End of range. |
Definition at line 5618 of file stl_algo.h.
|
inlineconstexpr |
Return the minimum element in a range using comparison functor.
__first | Start of range. |
__last | End of range. |
__comp | Comparison functor. |
Definition at line 5643 of file stl_algo.h.
|
inlineconstexpr |
Determines min and max at once as an ordered pair.
__a | A thing of arbitrary type. |
__b | Another thing of arbitrary type. |
Definition at line 3290 of file stl_algo.h.
|
inlineconstexpr |
Determines min and max at once as an ordered pair.
__a | A thing of arbitrary type. |
__b | Another thing of arbitrary type. |
__comp | A comparison functor . |
Definition at line 3311 of file stl_algo.h.
|
inlineconstexpr |
Return a pair of iterators pointing to the minimum and maximum elements in a range.
__first | Start of range. |
__last | End of range. |
Definition at line 3391 of file stl_algo.h.
|
inlineconstexpr |
Return a pair of iterators pointing to the minimum and maximum elements in a range.
__first | Start of range. |
__last | End of range. |
__comp | Comparison functor. |
Definition at line 3419 of file stl_algo.h.
|
inlineconstexpr |
Permute range into the next dictionary ordering.
__first | Start of range. |
__last | End of range. |
Treats all permutations of the range as a set of dictionary sorted sequences. Permutes the current sequence into the next one of this set. Returns true if there are more sequences to generate. If the sequence is the largest of the set, the smallest is generated and false returned.
Definition at line 2941 of file stl_algo.h.
|
inlineconstexpr |
Permute range into the next dictionary ordering using comparison functor.
__first | Start of range. |
__last | End of range. |
__comp | A comparison functor. |
Treats all permutations of the range [__first,__last) as a set of dictionary sorted sequences ordered by __comp
. Permutes the current sequence into the next one of this set. Returns true if there are more sequences to generate. If the sequence is the largest of the set, the smallest is generated and false returned.
Definition at line 2974 of file stl_algo.h.
|
inlineconstexpr |
Sort a sequence just enough to find a particular position.
__first | An iterator. |
__nth | Another iterator. |
__last | Another iterator. |
Rearranges the elements in the range [__first, __last)
so that *__nth
is the same element that would have been in that position had the whole sequence been sorted. The elements either side of *__nth
are not completely sorted, but for any iterator i
in the range [__first, __nth)
and any iterator j
in the range [__nth, __last)
it holds that *j < *i
is false.
Definition at line 4733 of file stl_algo.h.
References std::__lg().
|
inlineconstexpr |
Sort a sequence just enough to find a particular position using a predicate for comparison.
__first | An iterator. |
__nth | Another iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Rearranges the elements in the range [__first, __last)
so that *__nth
is the same element that would have been in that position had the whole sequence been sorted. The elements either side of *__nth
are not completely sorted, but for any iterator i
in the range [__first, __nth)
and any iterator j
in the range [__nth, __last)
it holds that __comp(*j, *i)
is false.
Definition at line 4773 of file stl_algo.h.
References std::__lg().
|
inlineconstexpr |
Sort the smallest elements of a sequence.
__first | An iterator. |
__middle | Another iterator. |
__last | Another iterator. |
Sorts the smallest (__middle - __first)
elements in the range [first, last)
and moves them to the range [__first, __middle)
. The order of the remaining elements in the range [__middle, __last)
is unspecified. After the sort if i
and j
are iterators in the range [__first, __middle)
such that i
precedes j
and k
is an iterator in the range [__middle, __last)
then *j < *i
and *k < *i
are both false.
Definition at line 4657 of file stl_algo.h.
|
inlineconstexpr |
Sort the smallest elements of a sequence using a predicate for comparison.
__first | An iterator. |
__middle | Another iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Sorts the smallest (__middle - __first)
elements in the range [__first, __last)
and moves them to the range [__first, __middle)
. The order of the remaining elements in the range [__middle, __last)
is unspecified. After the sort if i
and j
are iterators in the range [__first, __middle)
such that i
precedes j
and k
is an iterator in the range [__middle, __last)
then *__comp(j, *i)
and __comp(*k, *i)
are both false.
Definition at line 4696 of file stl_algo.h.
|
inlineconstexpr |
Copy the smallest elements of a sequence.
__first | An iterator. |
__last | Another iterator. |
__result_first | A random-access iterator. |
__result_last | Another random-access iterator. |
Copies and sorts the smallest N
values from the range [__first, __last)
to the range beginning at __result_first
, where the number of elements to be copied, N
, is the smaller of (__last - __first)
and (__result_last - __result_first)
. After the sort if i
and j
are iterators in the range [__result_first,__result_first + N)
such that i
precedes j
then *j < *i
is false. The value returned is __result_first + N
.
Definition at line 1699 of file stl_algo.h.
|
inlineconstexpr |
Copy the smallest elements of a sequence using a predicate for comparison.
__first | An input iterator. |
__last | Another input iterator. |
__result_first | A random-access iterator. |
__result_last | Another random-access iterator. |
__comp | A comparison functor. |
Copies and sorts the smallest N
values from the range [__first, __last)
to the range beginning at result_first
, where the number of elements to be copied, N
, is the smaller of (__last - __first)
and (__result_last - __result_first)
. After the sort if i
and j
are iterators in the range [__result_first, __result_first + N)
such that i
precedes j
then __comp(*j, *i)
is false. The value returned is __result_first + N
.
Definition at line 1750 of file stl_algo.h.
|
inlineconstexpr |
Permute range into the previous dictionary ordering.
__first | Start of range. |
__last | End of range. |
Treats all permutations of the range as a set of dictionary sorted sequences. Permutes the current sequence into the previous one of this set. Returns true if there are more sequences to generate. If the sequence is the smallest of the set, the largest is generated and false returned.
Definition at line 3044 of file stl_algo.h.
|
inlineconstexpr |
Permute range into the previous dictionary ordering using comparison functor.
__first | Start of range. |
__last | End of range. |
__comp | A comparison functor. |
Treats all permutations of the range [__first,__last) as a set of dictionary sorted sequences ordered by __comp
. Permutes the current sequence into the previous one of this set. Returns true if there are more sequences to generate. If the sequence is the smallest of the set, the largest is generated and false returned.
Definition at line 3077 of file stl_algo.h.
|
inlineconstexpr |
Sort the elements of a sequence.
__first | An iterator. |
__last | Another iterator. |
Sorts the elements in the range [__first, __last)
in ascending order, such that for each iterator i
in the range [__first, __last - 1)
, *(i+1) < *i
is false.
The relative ordering of equivalent elements is not preserved, use stable_sort()
if this is needed.
Definition at line 4811 of file stl_algo.h.
|
inlineconstexpr |
Sort the elements of a sequence using a predicate for comparison.
__first | An iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Sorts the elements in the range [__first, __last)
in ascending order, such that __comp(*(i+1), *i)
is false for every iterator i
in the range [__first, __last - 1)
.
The relative ordering of equivalent elements is not preserved, use stable_sort()
if this is needed.
Definition at line 4842 of file stl_algo.h.
|
inline |
Sort the elements of a sequence, preserving the relative order of equivalent elements.
__first | An iterator. |
__last | Another iterator. |
Sorts the elements in the range [__first,__last) in ascending order, such that for each iterator
i
in the range [__first,__last-1),
*
(i+1)<*i is false.
The relative ordering of equivalent elements is preserved, so any two elements x
and y
in the range [__first,__last) such that
x<y
is false and y<x
is false will have the same relative ordering after calling stable_sort()
.
Definition at line 5025 of file stl_algo.h.
|
inline |
Sort the elements of a sequence using a predicate for comparison, preserving the relative order of equivalent elements.
__first | An iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Sorts the elements in the range [__first,__last) in ascending order, such that for each iterator
i
in the range [__first,__last-1),
__comp
(*(i+1),*i) is false.
The relative ordering of equivalent elements is preserved, so any two elements x
and y
in the range [__first,__last) such that
__comp(x,y)
is false and __comp(y,x)
is false will have the same relative ordering after calling stable_sort()
.
Definition at line 5059 of file stl_algo.h.