2004-02-01 Paolo Carlini <pcarlini@suse.de>
+ * include/bits/stl_algo.h: Additional minor tweaks.
+ * include/bits/stl_map.h: Likewise.
+ * include/bits/stl_multimap.h: Likewise.
+ * include/bits/stl_multiset.h: Likewise.
+ * include/bits/stl_set.h: Likewise.
+ * include/bits/stl_tree.h: Likewise.
+
+2004-02-01 Paolo Carlini <pcarlini@suse.de>
+
* include/bits/vector.tcc (vector::_M_insert_aux(iterator)):
Remove, unused.
* @ingroup SGIextensions
*/
template<typename _Tp>
- inline const _Tp&
+ inline const _Tp&
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c)
{
// concept requirements
template<typename _InputIterator, typename _Tp>
inline _InputIterator
find(_InputIterator __first, _InputIterator __last,
- const _Tp& __val,
- input_iterator_tag)
+ const _Tp& __val, input_iterator_tag)
{
while (__first != __last && !(*__first == __val))
++__first;
template<typename _InputIterator, typename _Predicate>
inline _InputIterator
find_if(_InputIterator __first, _InputIterator __last,
- _Predicate __pred,
- input_iterator_tag)
+ _Predicate __pred, input_iterator_tag)
{
while (__first != __last && !__pred(*__first))
++__first;
template<typename _RandomAccessIterator, typename _Tp>
_RandomAccessIterator
find(_RandomAccessIterator __first, _RandomAccessIterator __last,
- const _Tp& __val,
- random_access_iterator_tag)
+ const _Tp& __val, random_access_iterator_tag)
{
typename iterator_traits<_RandomAccessIterator>::difference_type
__trip_count = (__last - __first) >> 2;
template<typename _RandomAccessIterator, typename _Predicate>
_RandomAccessIterator
find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Predicate __pred,
- random_access_iterator_tag)
+ _Predicate __pred, random_access_iterator_tag)
{
typename iterator_traits<_RandomAccessIterator>::difference_type
__trip_count = (__last - __first) >> 2;
{
// concept requirements
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
- __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
- _BinaryFunctionConcept)
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
+ _BinaryFunctionConcept)
- public:
+ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const _Key, _Tp> value_type;
_Compare comp;
value_compare(_Compare __c)
- : comp(__c) { }
+ : comp(__c) { }
public:
bool operator()(const value_type& __x, const value_type& __y) const
{ return _M_t.equal_range(__x); }
template <typename _K1, typename _T1, typename _C1, typename _A1>
- friend bool operator== (const map<_K1,_T1,_C1,_A1>&,
- const map<_K1,_T1,_C1,_A1>&);
+ friend bool
+ operator== (const map<_K1,_T1,_C1,_A1>&,
+ const map<_K1,_T1,_C1,_A1>&);
+
template <typename _K1, typename _T1, typename _C1, typename _A1>
- friend bool operator< (const map<_K1,_T1,_C1,_A1>&,
- const map<_K1,_T1,_C1,_A1>&);
+ friend bool
+ operator< (const map<_K1,_T1,_C1,_A1>&,
+ const map<_K1,_T1,_C1,_A1>&);
};
/**
template <typename _Key, typename _Tp,
typename _Compare = less<_Key>,
typename _Alloc = allocator<pair<const _Key, _Tp> > >
- class multimap;
+ class multimap;
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
+ inline bool
+ operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
- inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
- const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
+ inline bool
+ operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
+ const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
/**
* @brief A standard container made up of (key,value) pairs, which can be
_Compare comp;
value_compare(_Compare __c)
- : comp(__c) { }
+ : comp(__c) { }
public:
bool operator()(const value_type& __x, const value_type& __y) const
// Forward declaration of operators < and ==, needed for friend declaration.
template <class _Key, class _Compare = less<_Key>,
class _Alloc = allocator<_Key> >
- class multiset;
+ class multiset;
template <class _Key, class _Compare, class _Alloc>
- inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x,
- const multiset<_Key,_Compare,_Alloc>& __y);
+ inline bool
+ operator==(const multiset<_Key,_Compare,_Alloc>& __x,
+ const multiset<_Key,_Compare,_Alloc>& __y);
template <class _Key, class _Compare, class _Alloc>
- inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
- const multiset<_Key,_Compare,_Alloc>& __y);
+ inline bool
+ operator<(const multiset<_Key,_Compare,_Alloc>& __x,
+ const multiset<_Key,_Compare,_Alloc>& __y);
/**
* @brief A standard container made up of elements, which can be retrieved
// Forward declarations of operators < and ==, needed for friend declaration.
template<class _Key, class _Compare = less<_Key>,
class _Alloc = allocator<_Key> >
- class set;
+ class set;
template<class _Key, class _Compare, class _Alloc>
inline bool
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
- public:
+ public:
// typedefs:
//@{
/// Public typedefs.
{ return _M_node != __x._M_node; }
_Base_ptr _M_node;
- };
+ };
template<typename _Val>
inline bool
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc = allocator<_Val> >
class _Rb_tree
- : protected _Alloc::template rebind<_Rb_tree_node<_Val> >::other
+ : protected _Alloc::template rebind<_Rb_tree_node<_Val> >::other
{
typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
_Node_allocator;
public:
// allocation/deallocation
_Rb_tree()
- : _Node_allocator(allocator_type()),
- _M_node_count(0),
- _M_key_compare()
+ : _Node_allocator(allocator_type()),
+ _M_node_count(0),
+ _M_key_compare()
{ _M_empty_initialize(); }
_Rb_tree(const _Compare& __comp)
- : _Node_allocator(allocator_type()),
- _M_node_count(0),
- _M_key_compare(__comp)
+ : _Node_allocator(allocator_type()),
+ _M_node_count(0),
+ _M_key_compare(__comp)
{ _M_empty_initialize(); }
_Rb_tree(const _Compare& __comp, const allocator_type& __a)
- : _Node_allocator(__a),
- _M_node_count(0),
- _M_key_compare(__comp)
+ : _Node_allocator(__a),
+ _M_node_count(0),
+ _M_key_compare(__comp)
{ _M_empty_initialize(); }
_Rb_tree(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x)
- : _Node_allocator(__x.get_allocator()),
- _M_node_count(0),
- _M_key_compare(__x._M_key_compare)
+ : _Node_allocator(__x.get_allocator()),
+ _M_node_count(0),
+ _M_key_compare(__x._M_key_compare)
{
if (__x._M_root() == 0)
_M_empty_initialize();
_M_node_count = __x._M_node_count;
}
- ~_Rb_tree() { _M_erase(_M_begin()); }
+ ~_Rb_tree()
+ { _M_erase(_M_begin()); }
_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>&
operator=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x);
inline bool
operator<=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x,
const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y)
- { return !(__y < __x); }
+ { return !(__y < __x); }
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
inline bool
operator>=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x,
const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y)
- { return !(__x < __y); }
+ { return !(__x < __y); }
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
template<typename _Key, typename _Val, typename _KoV,
typename _Compare, typename _Alloc>
- inline
- pair<typename _Rb_tree<_Key, _Val, _KoV,
- _Compare, _Alloc>::const_iterator,
- typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::const_iterator>
- _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>
- ::equal_range(const _Key& __k) const
- { return pair<const_iterator, const_iterator>(lower_bound(__k),
- upper_bound(__k)); }
+ inline
+ pair<typename _Rb_tree<_Key, _Val, _KoV,
+ _Compare, _Alloc>::const_iterator,
+ typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::const_iterator>
+ _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
+ equal_range(const _Key& __k) const
+ { return pair<const_iterator, const_iterator>(lower_bound(__k),
+ upper_bound(__k)); }
unsigned int
_Rb_tree_black_count(const _Rb_tree_node_base* __node,
bool
_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
{
- if (_M_node_count == 0 || begin() == end())
- return _M_node_count == 0 && begin() == end()
- && this->_M_header._M_left == _M_end()
- && this->_M_header._M_right == _M_end();
+ if (_M_node_count == 0 || begin() == end())
+ return _M_node_count == 0 && begin() == end()
+ && this->_M_header._M_left == _M_end()
+ && this->_M_header._M_right == _M_end();
- unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
- for (const_iterator __it = begin(); __it != end(); ++__it)
- {
- _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node);
- _Const_Link_type __L = _S_left(__x);
- _Const_Link_type __R = _S_right(__x);
+ unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
+ for (const_iterator __it = begin(); __it != end(); ++__it)
+ {
+ _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node);
+ _Const_Link_type __L = _S_left(__x);
+ _Const_Link_type __R = _S_right(__x);
- if (__x->_M_color == _S_red)
- if ((__L && __L->_M_color == _S_red)
- || (__R && __R->_M_color == _S_red))
- return false;
+ if (__x->_M_color == _S_red)
+ if ((__L && __L->_M_color == _S_red)
+ || (__R && __R->_M_color == _S_red))
+ return false;
- if (__L && _M_key_compare(_S_key(__x), _S_key(__L)))
- return false;
- if (__R && _M_key_compare(_S_key(__R), _S_key(__x)))
- return false;
-
- if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
- return false;
- }
+ if (__L && _M_key_compare(_S_key(__x), _S_key(__L)))
+ return false;
+ if (__R && _M_key_compare(_S_key(__R), _S_key(__x)))
+ return false;
+
+ if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
+ return false;
+ }
- if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
- return false;
- if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
- return false;
- return true;
+ if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
+ return false;
+ if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
+ return false;
+ return true;
}
} // namespace std