libstdc++
|
void std::inplace_merge | ( | _BidirectionalIterator | __first, |
_BidirectionalIterator | __middle, | ||
_BidirectionalIterator | __last | ||
) |
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 3136 of file stl_algo.h.
References std::__merge_adaptive(), std::__merge_without_buffer(), std::_Temporary_buffer< _ForwardIterator, _Tp >::begin(), std::distance(), and std::_Temporary_buffer< _ForwardIterator, _Tp >::size().
void std::inplace_merge | ( | _BidirectionalIterator | __first, |
_BidirectionalIterator | __middle, | ||
_BidirectionalIterator | __last, | ||
_Compare | __comp | ||
) |
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 3191 of file stl_algo.h.
References std::__merge_adaptive(), std::__merge_without_buffer(), std::_Temporary_buffer< _ForwardIterator, _Tp >::begin(), std::distance(), and std::_Temporary_buffer< _ForwardIterator, _Tp >::size().
bool std::is_sorted | ( | _ForwardIterator | __first, |
_ForwardIterator | __last | ||
) | [inline] |
Determines whether the elements of a sequence are sorted.
__first | An iterator. |
__last | Another iterator. |
Definition at line 3934 of file stl_algo.h.
References std::is_sorted_until().
bool std::is_sorted | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_Compare | __comp | ||
) | [inline] |
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 3948 of file stl_algo.h.
References std::is_sorted_until().
_ForwardIterator std::is_sorted_until | ( | _ForwardIterator | __first, |
_ForwardIterator | __last | ||
) |
Determines the end of a sorted sequence.
__first | An iterator. |
__last | Another iterator. |
Definition at line 3962 of file stl_algo.h.
_ForwardIterator std::is_sorted_until | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_Compare | __comp | ||
) |
Determines the end of a sorted sequence using comparison functor.
__first | An iterator. |
__last | Another iterator. |
__comp | A comparison functor. |
Definition at line 3991 of file stl_algo.h.
Referenced by std::is_sorted().
bool std::lexicographical_compare | ( | _II1 | __first1, |
_II1 | __last1, | ||
_II2 | __first2, | ||
_II2 | __last2 | ||
) | [inline] |
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 1074 of file stl_algobase.h.
bool std::lexicographical_compare | ( | _II1 | __first1, |
_II1 | __last1, | ||
_II2 | __first2, | ||
_II2 | __last2, | ||
_Compare | __comp | ||
) |
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 1108 of file stl_algobase.h.
Referenced by std::operator<().
const _Tp & std::max | ( | const _Tp & | __a, |
const _Tp & | __b | ||
) | [inline] |
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 210 of file stl_algobase.h.
Referenced by std::_Deque_base< _Tp, _Alloc >::_M_initialize_map(), std::deque< _Tp, _Alloc >::_M_reallocate_map(), std::tr2::dynamic_bitset< _WordT, _Alloc >::max_size(), and std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow().
const _Tp & std::max | ( | const _Tp & | __a, |
const _Tp & | __b, | ||
_Compare | __comp | ||
) | [inline] |
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 254 of file stl_algobase.h.
_ForwardIterator std::max_element | ( | _ForwardIterator | __first, |
_ForwardIterator | __last | ||
) |
Return the maximum element in a range.
__first | Start of range. |
__last | End of range. |
Definition at line 6257 of file stl_algo.h.
_ForwardIterator std::max_element | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_Compare | __comp | ||
) |
Return the maximum element in a range using comparison functor.
__first | Start of range. |
__last | End of range. |
__comp | Comparison functor. |
Definition at line 6285 of file stl_algo.h.
Referenced by std::valarray< _Tp >::max().
_OutputIterator std::merge | ( | _InputIterator1 | __first1, |
_InputIterator1 | __last1, | ||
_InputIterator2 | __first2, | ||
_InputIterator2 | __last2, | ||
_OutputIterator | __result | ||
) |
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. |
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 5499 of file stl_algo.h.
_OutputIterator std::merge | ( | _InputIterator1 | __first1, |
_InputIterator1 | __last1, | ||
_InputIterator2 | __first2, | ||
_InputIterator2 | __last2, | ||
_OutputIterator | __result, | ||
_Compare | __comp | ||
) |
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. |
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 5563 of file stl_algo.h.
const _Tp & std::min | ( | const _Tp & | __a, |
const _Tp & | __b | ||
) | [inline] |
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 187 of file stl_algobase.h.
Referenced by __gnu_profile::__report(), __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, _Base >::compare(), std::basic_string< char >::compare(), std::basic_string< _CharT, _Traits, _Alloc >::compare(), std::generate_canonical(), std::basic_stringbuf< _CharT, _Traits, _Alloc >::overflow(), __gnu_cxx::random_sample_n(), 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, _Traits >::underflow(), std::basic_streambuf< _CharT, _Traits >::xsgetn(), std::basic_filebuf< _CharT, _Traits >::xsputn(), and std::basic_streambuf< _CharT, _Traits >::xsputn().
const _Tp & std::min | ( | const _Tp & | __a, |
const _Tp & | __b, | ||
_Compare | __comp | ||
) | [inline] |
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 233 of file stl_algobase.h.
_ForwardIterator std::min_element | ( | _ForwardIterator | __first, |
_ForwardIterator | __last | ||
) |
Return the minimum element in a range.
__first | Start of range. |
__last | End of range. |
Definition at line 6201 of file stl_algo.h.
_ForwardIterator std::min_element | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_Compare | __comp | ||
) |
Return the minimum element in a range using comparison functor.
__first | Start of range. |
__last | End of range. |
__comp | Comparison functor. |
Definition at line 6229 of file stl_algo.h.
Referenced by std::valarray< _Tp >::min().
pair< const _Tp &, const _Tp & > std::minmax | ( | const _Tp & | __a, |
const _Tp & | __b | ||
) | [inline] |
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 4021 of file stl_algo.h.
pair< const _Tp &, const _Tp & > std::minmax | ( | const _Tp & | __a, |
const _Tp & | __b, | ||
_Compare | __comp | ||
) | [inline] |
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 4041 of file stl_algo.h.
pair<_ForwardIterator, _ForwardIterator> std::minmax_element | ( | _ForwardIterator | __first, |
_ForwardIterator | __last | ||
) |
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 4060 of file stl_algo.h.
References std::make_pair().
pair<_ForwardIterator, _ForwardIterator> std::minmax_element | ( | _ForwardIterator | __first, |
_ForwardIterator | __last, | ||
_Compare | __comp | ||
) |
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 4136 of file stl_algo.h.
References std::make_pair().
bool std::next_permutation | ( | _BidirectionalIterator | __first, |
_BidirectionalIterator | __last | ||
) |
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 3636 of file stl_algo.h.
References std::iter_swap(), and std::reverse().
bool std::next_permutation | ( | _BidirectionalIterator | __first, |
_BidirectionalIterator | __last, | ||
_Compare | __comp | ||
) |
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 3693 of file stl_algo.h.
References std::iter_swap(), and std::reverse().
void std::nth_element | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __nth, | ||
_RandomAccessIterator | __last | ||
) | [inline] |
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 5343 of file stl_algo.h.
References std::__lg().
void std::nth_element | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __nth, | ||
_RandomAccessIterator | __last, | ||
_Compare | __comp | ||
) | [inline] |
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 5382 of file stl_algo.h.
References std::__lg().
void std::partial_sort | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __middle, | ||
_RandomAccessIterator | __last | ||
) | [inline] |
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 undefined. 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 5267 of file stl_algo.h.
References std::__heap_select(), and std::sort_heap().
void std::partial_sort | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __middle, | ||
_RandomAccessIterator | __last, | ||
_Compare | __comp | ||
) | [inline] |
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 undefined. 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 5306 of file stl_algo.h.
References std::__heap_select(), and std::sort_heap().
_RandomAccessIterator std::partial_sort_copy | ( | _InputIterator | __first, |
_InputIterator | __last, | ||
_RandomAccessIterator | __result_first, | ||
_RandomAccessIterator | __result_last | ||
) |
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 1957 of file stl_algo.h.
References std::make_heap(), and std::sort_heap().
_RandomAccessIterator std::partial_sort_copy | ( | _InputIterator | __first, |
_InputIterator | __last, | ||
_RandomAccessIterator | __result_first, | ||
_RandomAccessIterator | __result_last, | ||
_Compare | __comp | ||
) |
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 2023 of file stl_algo.h.
References std::make_heap(), and std::sort_heap().
bool std::prev_permutation | ( | _BidirectionalIterator | __first, |
_BidirectionalIterator | __last | ||
) |
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 3749 of file stl_algo.h.
References std::iter_swap(), and std::reverse().
bool std::prev_permutation | ( | _BidirectionalIterator | __first, |
_BidirectionalIterator | __last, | ||
_Compare | __comp | ||
) |
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 3806 of file stl_algo.h.
References std::iter_swap(), and std::reverse().
void std::sort | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __last | ||
) | [inline] |
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 5420 of file stl_algo.h.
References std::__final_insertion_sort(), std::__introsort_loop(), and std::__lg().
void std::sort | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __last, | ||
_Compare | __comp | ||
) | [inline] |
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 5456 of file stl_algo.h.
References std::__final_insertion_sort(), std::__introsort_loop(), and std::__lg().
void std::stable_sort | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __last | ||
) | [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 5622 of file stl_algo.h.
References std::__inplace_stable_sort(), std::_Temporary_buffer< _ForwardIterator, _Tp >::begin(), and std::_Temporary_buffer< _ForwardIterator, _Tp >::size().
void std::stable_sort | ( | _RandomAccessIterator | __first, |
_RandomAccessIterator | __last, | ||
_Compare | __comp | ||
) | [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 5664 of file stl_algo.h.
References std::__inplace_stable_sort(), std::_Temporary_buffer< _ForwardIterator, _Tp >::begin(), and std::_Temporary_buffer< _ForwardIterator, _Tp >::size().