stl_algo.h: Wrap overlong lines...
2004-01-31 Paolo Carlini <pcarlini@suse.de> * include/bits/stl_algo.h: Wrap overlong lines, constify a few variables, reformat according to the coding standards. * include/bits/stl_algobase.h: Likewise. * include/bits/stl_heap.h: Likewise. From-SVN: r77050
This commit is contained in:
parent
fdf064f28d
commit
ffa67767d0
@ -1,3 +1,10 @@
|
||||
2004-01-31 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/stl_algo.h: Wrap overlong lines, constify
|
||||
a few variables, reformat according to the coding standards.
|
||||
* include/bits/stl_algobase.h: Likewise.
|
||||
* include/bits/stl_heap.h: Likewise.
|
||||
|
||||
2004-01-31 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/basic_string.h (_Rep::operator[]): Remove, unused.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -91,16 +91,22 @@ namespace std
|
||||
inline void
|
||||
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type _ValueType1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type _ValueType2;
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type
|
||||
_ValueType1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type
|
||||
_ValueType2;
|
||||
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIterator1>)
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIterator2>)
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_ValueType1, _ValueType2>)
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_ValueType2, _ValueType1>)
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
|
||||
_ForwardIterator1>)
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
|
||||
_ForwardIterator2>)
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_ValueType1,
|
||||
_ValueType2>)
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_ValueType2,
|
||||
_ValueType1>)
|
||||
|
||||
_ValueType1 __tmp = *__a;
|
||||
const _ValueType1 __tmp = *__a;
|
||||
*__a = *__b;
|
||||
*__b = __tmp;
|
||||
}
|
||||
@ -121,7 +127,7 @@ namespace std
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
|
||||
|
||||
_Tp __tmp = __a;
|
||||
const _Tp __tmp = __a;
|
||||
__a = __b;
|
||||
__b = __tmp;
|
||||
}
|
||||
@ -146,7 +152,9 @@ namespace std
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
|
||||
//return __b < __a ? __b : __a;
|
||||
if (__b < __a) return __b; return __a;
|
||||
if (__b < __a)
|
||||
return __b;
|
||||
return __a;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,7 +174,9 @@ namespace std
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
|
||||
//return __a < __b ? __b : __a;
|
||||
if (__a < __b) return __b; return __a;
|
||||
if (__a < __b)
|
||||
return __b;
|
||||
return __a;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +194,9 @@ namespace std
|
||||
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
//return __comp(__b, __a) ? __b : __a;
|
||||
if (__comp(__b, __a)) return __b; return __a;
|
||||
if (__comp(__b, __a))
|
||||
return __b;
|
||||
return __a;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,7 +214,9 @@ namespace std
|
||||
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
|
||||
{
|
||||
//return __comp(__a, __b) ? __b : __a;
|
||||
if (__comp(__a, __b)) return __b; return __a;
|
||||
if (__comp(__a, __b))
|
||||
return __b;
|
||||
return __a;
|
||||
}
|
||||
|
||||
// All of these auxiliary functions serve two purposes. (1) Replace
|
||||
@ -249,13 +263,15 @@ namespace std
|
||||
inline _OutputIterator
|
||||
__copy_aux2(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, __false_type)
|
||||
{ return std::__copy(__first, __last, __result, std::__iterator_category(__first)); }
|
||||
{ return std::__copy(__first, __last, __result,
|
||||
std::__iterator_category(__first)); }
|
||||
|
||||
template<typename _InputIterator, typename _OutputIterator>
|
||||
inline _OutputIterator
|
||||
__copy_aux2(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, __true_type)
|
||||
{ return std::__copy(__first, __last, __result, std::__iterator_category(__first)); }
|
||||
{ return std::__copy(__first, __last, __result,
|
||||
std::__iterator_category(__first)); }
|
||||
|
||||
template<typename _Tp>
|
||||
inline _Tp*
|
||||
@ -274,9 +290,9 @@ namespace std
|
||||
_OutputIterator __result, __true_type)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type
|
||||
_ValueType;
|
||||
typedef typename __type_traits<_ValueType>::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
_ValueType;
|
||||
typedef typename __type_traits<
|
||||
_ValueType>::has_trivial_assignment_operator _Trivial;
|
||||
return _OutputIterator(std::__copy_aux2(__first, __last, __result.base(),
|
||||
_Trivial()));
|
||||
}
|
||||
@ -287,8 +303,8 @@ namespace std
|
||||
_OutputIterator __result, __false_type)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
|
||||
typedef typename __type_traits<_ValueType>::has_trivial_assignment_operator
|
||||
_Trivial;
|
||||
typedef typename __type_traits<
|
||||
_ValueType>::has_trivial_assignment_operator _Trivial;
|
||||
return std::__copy_aux2(__first, __last, __result, _Trivial());
|
||||
}
|
||||
|
||||
@ -298,7 +314,8 @@ namespace std
|
||||
_OutputIterator __result, __true_type)
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_OutputIterator>::_Normal __Normal;
|
||||
return std::__copy_ni2(__first.base(), __last.base(), __result, __Normal());
|
||||
return std::__copy_ni2(__first.base(), __last.base(),
|
||||
__result, __Normal());
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _OutputIterator>
|
||||
@ -328,7 +345,8 @@ namespace std
|
||||
*/
|
||||
template<typename _InputIterator, typename _OutputIterator>
|
||||
inline _OutputIterator
|
||||
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
|
||||
copy(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
@ -342,8 +360,10 @@ namespace std
|
||||
|
||||
template<typename _BidirectionalIterator1, typename _BidirectionalIterator2>
|
||||
inline _BidirectionalIterator2
|
||||
__copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
|
||||
_BidirectionalIterator2 __result, bidirectional_iterator_tag)
|
||||
__copy_backward(_BidirectionalIterator1 __first,
|
||||
_BidirectionalIterator1 __last,
|
||||
_BidirectionalIterator2 __result,
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
while (__first != __last)
|
||||
*--__result = *--__last;
|
||||
@ -373,10 +393,8 @@ namespace std
|
||||
static _BidirectionalIterator2
|
||||
copy(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
|
||||
_BidirectionalIterator2 __result)
|
||||
{
|
||||
return std::__copy_backward(__first, __last, __result,
|
||||
std::__iterator_category(__first));
|
||||
}
|
||||
{ return std::__copy_backward(__first, __last, __result,
|
||||
std::__iterator_category(__first)); }
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
@ -408,9 +426,10 @@ namespace std
|
||||
{
|
||||
typedef typename __type_traits<typename iterator_traits<_BI2>::value_type>
|
||||
::has_trivial_assignment_operator _Trivial;
|
||||
return std::__copy_backward_dispatch<_BI1, _BI2, _Trivial>::copy(__first,
|
||||
__last,
|
||||
__result);
|
||||
return
|
||||
std::__copy_backward_dispatch<_BI1, _BI2, _Trivial>::copy(__first,
|
||||
__last,
|
||||
__result);
|
||||
}
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
@ -432,8 +451,8 @@ namespace std
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal;
|
||||
return std::__copy_backward_output_normal_iterator(__first.base(),
|
||||
__last.base(), __result,
|
||||
__Normal());
|
||||
__last.base(),
|
||||
__result, __Normal());
|
||||
}
|
||||
|
||||
template <typename _BI1, typename _BI2>
|
||||
@ -442,8 +461,8 @@ namespace std
|
||||
_BI2 __result, __false_type)
|
||||
{
|
||||
typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal;
|
||||
return std::__copy_backward_output_normal_iterator(__first, __last, __result,
|
||||
__Normal());
|
||||
return std::__copy_backward_output_normal_iterator(__first, __last,
|
||||
__result, __Normal());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -476,8 +495,8 @@ namespace std
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal;
|
||||
return std::__copy_backward_input_normal_iterator(__first, __last, __result,
|
||||
__Normal());
|
||||
return std::__copy_backward_input_normal_iterator(__first, __last,
|
||||
__result, __Normal());
|
||||
}
|
||||
|
||||
|
||||
@ -497,7 +516,8 @@ namespace std
|
||||
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
|
||||
_ForwardIterator>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
for ( ; __first != __last; ++__first)
|
||||
@ -532,7 +552,7 @@ namespace std
|
||||
fill(unsigned char* __first, unsigned char* __last, const unsigned char& __c)
|
||||
{
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
unsigned char __tmp = __c;
|
||||
const unsigned char __tmp = __c;
|
||||
std::memset(__first, __tmp, __last - __first);
|
||||
}
|
||||
|
||||
@ -540,7 +560,7 @@ namespace std
|
||||
fill(signed char* __first, signed char* __last, const signed char& __c)
|
||||
{
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
signed char __tmp = __c;
|
||||
const signed char __tmp = __c;
|
||||
std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
|
||||
}
|
||||
|
||||
@ -548,7 +568,7 @@ namespace std
|
||||
fill(char* __first, char* __last, const char& __c)
|
||||
{
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
char __tmp = __c;
|
||||
const char __tmp = __c;
|
||||
std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
|
||||
}
|
||||
|
||||
@ -625,7 +645,8 @@ namespace std
|
||||
* second iterator points into the second range, and the elements pointed
|
||||
* to by the iterators are not equal.
|
||||
*/
|
||||
template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate>
|
||||
template<typename _InputIterator1, typename _InputIterator2,
|
||||
typename _BinaryPredicate>
|
||||
pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _BinaryPredicate __binary_pred)
|
||||
@ -656,7 +677,8 @@ namespace std
|
||||
*/
|
||||
template<typename _InputIterator1, typename _InputIterator2>
|
||||
inline bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
|
||||
@ -685,7 +707,8 @@ namespace std
|
||||
* false depending on whether all of the corresponding elements of the
|
||||
* ranges are equal.
|
||||
*/
|
||||
template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate>
|
||||
template<typename _InputIterator1, typename _InputIterator2,
|
||||
typename _BinaryPredicate>
|
||||
inline bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2,
|
||||
@ -753,7 +776,8 @@ namespace std
|
||||
* The same as the four-parameter @c lexigraphical_compare, but uses the
|
||||
* comp parameter instead of @c <.
|
||||
*/
|
||||
template<typename _InputIterator1, typename _InputIterator2, typename _Compare>
|
||||
template<typename _InputIterator1, typename _InputIterator2,
|
||||
typename _Compare>
|
||||
bool
|
||||
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2,
|
||||
@ -787,7 +811,8 @@ namespace std
|
||||
|
||||
const size_t __len1 = __last1 - __first1;
|
||||
const size_t __len2 = __last2 - __first2;
|
||||
const int __result = std::memcmp(__first1, __first2, std::min(__len1, __len2));
|
||||
const int __result = std::memcmp(__first1, __first2,
|
||||
std::min(__len1, __len2));
|
||||
return __result != 0 ? __result < 0 : __len1 < __len2;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Heap implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -72,12 +72,13 @@ namespace std
|
||||
__is_heap(_RandomAccessIterator __first, _Distance __n)
|
||||
{
|
||||
_Distance __parent = 0;
|
||||
for (_Distance __child = 1; __child < __n; ++__child) {
|
||||
if (__first[__parent] < __first[__child])
|
||||
return false;
|
||||
if ((__child & 1) == 0)
|
||||
++__parent;
|
||||
}
|
||||
for (_Distance __child = 1; __child < __n; ++__child)
|
||||
{
|
||||
if (__first[__parent] < __first[__child])
|
||||
return false;
|
||||
if ((__child & 1) == 0)
|
||||
++__parent;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -88,12 +89,13 @@ namespace std
|
||||
_Distance __n)
|
||||
{
|
||||
_Distance __parent = 0;
|
||||
for (_Distance __child = 1; __child < __n; ++__child) {
|
||||
if (__comp(__first[__parent], __first[__child]))
|
||||
return false;
|
||||
if ((__child & 1) == 0)
|
||||
++__parent;
|
||||
}
|
||||
for (_Distance __child = 1; __child < __n; ++__child)
|
||||
{
|
||||
if (__comp(__first[__parent], __first[__child]))
|
||||
return false;
|
||||
if ((__child & 1) == 0)
|
||||
++__parent;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -116,11 +118,12 @@ namespace std
|
||||
_Distance __holeIndex, _Distance __topIndex, _Tp __value)
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && *(__first + __parent) < __value) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
while (__holeIndex > __topIndex && *(__first + __parent) < __value)
|
||||
{
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(__first + __holeIndex) = __value;
|
||||
}
|
||||
|
||||
@ -149,8 +152,8 @@ namespace std
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
// __glibcxx_requires_heap(__first, __last - 1);
|
||||
|
||||
std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
|
||||
_ValueType(*(__last - 1)));
|
||||
std::__push_heap(__first, _DistanceType((__last - __first) - 1),
|
||||
_DistanceType(0), _ValueType(*(__last - 1)));
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator, typename _Distance, typename _Tp,
|
||||
@ -160,11 +163,13 @@ namespace std
|
||||
_Distance __topIndex, _Tp __value, _Compare __comp)
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
while (__holeIndex > __topIndex
|
||||
&& __comp(*(__first + __parent), __value))
|
||||
{
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(__first + __holeIndex) = __value;
|
||||
}
|
||||
|
||||
@ -195,8 +200,8 @@ namespace std
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
__glibcxx_requires_heap_pred(__first, __last - 1, __comp);
|
||||
|
||||
std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0),
|
||||
_ValueType(*(__last - 1)), __comp);
|
||||
std::__push_heap(__first, _DistanceType((__last - __first) - 1),
|
||||
_DistanceType(0), _ValueType(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
|
||||
@ -204,19 +209,21 @@ namespace std
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __value)
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
const _Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (__secondChild == __len) {
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
while (__secondChild < __len)
|
||||
{
|
||||
if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (__secondChild == __len)
|
||||
{
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
std::__push_heap(__first, __holeIndex, __topIndex, __value);
|
||||
}
|
||||
|
||||
@ -225,9 +232,11 @@ namespace std
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
_Distance;
|
||||
*__result = *__first;
|
||||
std::__adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);
|
||||
std::__adjust_heap(__first, _Distance(0), _Distance(__last - __first),
|
||||
__value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +252,8 @@ namespace std
|
||||
inline void
|
||||
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type
|
||||
_ValueType;
|
||||
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
@ -252,7 +262,8 @@ namespace std
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
__glibcxx_requires_heap(__first, __last);
|
||||
|
||||
std::__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)));
|
||||
std::__pop_heap(__first, __last - 1, __last - 1,
|
||||
_ValueType(*(__last - 1)));
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator, typename _Distance,
|
||||
@ -261,19 +272,22 @@ namespace std
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __value, _Compare __comp)
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
const _Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1))))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (__secondChild == __len) {
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
while (__secondChild < __len)
|
||||
{
|
||||
if (__comp(*(__first + __secondChild),
|
||||
*(__first + (__secondChild - 1))))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (__secondChild == __len)
|
||||
{
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
std::__push_heap(__first, __holeIndex, __topIndex, __value, __comp);
|
||||
}
|
||||
|
||||
@ -282,9 +296,10 @@ namespace std
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __value, _Compare __comp)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance;
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type
|
||||
_Distance;
|
||||
*__result = *__first;
|
||||
std::__adjust_heap(__first, _Distance(0), _Distance(__last - __first),
|
||||
std::__adjust_heap(__first, _Distance(0), _Distance(__last - __first),
|
||||
__value, __comp);
|
||||
}
|
||||
|
||||
@ -310,8 +325,10 @@ namespace std
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
__glibcxx_requires_heap_pred(__first, __last, __comp);
|
||||
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType;
|
||||
std::__pop_heap(__first, __last - 1, __last - 1, _ValueType(*(__last - 1)), __comp);
|
||||
typedef typename iterator_traits<_RandomAccessIterator>::value_type
|
||||
_ValueType;
|
||||
std::__pop_heap(__first, __last - 1, __last - 1,
|
||||
_ValueType(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -337,15 +354,19 @@ namespace std
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<_ValueType>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
if (__last - __first < 2) return;
|
||||
_DistanceType __len = __last - __first;
|
||||
_DistanceType __parent = (__len - 2)/2;
|
||||
|
||||
while (true) {
|
||||
std::__adjust_heap(__first, __parent, __len, _ValueType(*(__first + __parent)));
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
if (__last - __first < 2)
|
||||
return;
|
||||
|
||||
const _DistanceType __len = __last - __first;
|
||||
_DistanceType __parent = (__len - 2) / 2;
|
||||
while (true)
|
||||
{
|
||||
std::__adjust_heap(__first, __parent, __len,
|
||||
_ValueType(*(__first + __parent)));
|
||||
if (__parent == 0)
|
||||
return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,16 +394,19 @@ namespace std
|
||||
_RandomAccessIterator>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
if (__last - __first < 2) return;
|
||||
_DistanceType __len = __last - __first;
|
||||
_DistanceType __parent = (__len - 2)/2;
|
||||
|
||||
while (true) {
|
||||
std::__adjust_heap(__first, __parent, __len,
|
||||
_ValueType(*(__first + __parent)), __comp);
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
if (__last - __first < 2)
|
||||
return;
|
||||
|
||||
const _DistanceType __len = __last - __first;
|
||||
_DistanceType __parent = (__len - 2) / 2;
|
||||
while (true)
|
||||
{
|
||||
std::__adjust_heap(__first, __parent, __len,
|
||||
_ValueType(*(__first + __parent)), __comp);
|
||||
if (__parent == 0)
|
||||
return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user