diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-02-01 23:19:55 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-02-01 23:19:55 +0000 |
commit | 737ab798c540e618feb09873a810d808e71bf10a (patch) | |
tree | aefc0d7e28408ed8c489c89aa49e2a9619460304 | |
parent | 64ebadacc4ee75f95596174273b89bebbc0dfb01 (diff) | |
download | gcc-737ab798c540e618feb09873a810d808e71bf10a.zip gcc-737ab798c540e618feb09873a810d808e71bf10a.tar.gz gcc-737ab798c540e618feb09873a810d808e71bf10a.tar.bz2 |
stl_algo.h: Additional minor tweaks.
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.
From-SVN: r77082
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 14 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_map.h | 19 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_multimap.h | 14 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_multiset.h | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_set.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_tree.h | 105 |
7 files changed, 95 insertions, 82 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index cef5af5..8e8365a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,14 @@ 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. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 1ea8902..f33d4e3 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -82,7 +82,7 @@ namespace std * @ingroup SGIextensions */ template<typename _Tp> - inline const _Tp& + inline const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) { // concept requirements @@ -167,8 +167,7 @@ namespace std 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; @@ -183,8 +182,7 @@ namespace std 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; @@ -199,8 +197,7 @@ namespace std 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; @@ -252,8 +249,7 @@ namespace std 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; diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index e86f488..6cb0845 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -92,10 +92,10 @@ namespace __gnu_norm { // 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; @@ -109,7 +109,7 @@ namespace __gnu_norm _Compare comp; value_compare(_Compare __c) - : comp(__c) { } + : comp(__c) { } public: bool operator()(const value_type& __x, const value_type& __y) const @@ -613,11 +613,14 @@ namespace __gnu_norm { 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>&); }; /** diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index cfd28ef..4f442b8 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -70,15 +70,17 @@ namespace __gnu_norm 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 @@ -123,7 +125,7 @@ namespace __gnu_norm _Compare comp; value_compare(_Compare __c) - : comp(__c) { } + : comp(__c) { } public: bool operator()(const value_type& __x, const value_type& __y) const diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index c72d993..f085a00 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -69,15 +69,17 @@ namespace __gnu_norm // 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 diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 1e45f99..75fa7f5 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -68,7 +68,7 @@ namespace __gnu_norm // 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 @@ -111,7 +111,7 @@ namespace __gnu_norm __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) - public: + public: // typedefs: //@{ /// Public typedefs. diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 9eeccab..f0d36b7 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -289,7 +289,7 @@ namespace std { return _M_node != __x._M_node; } _Base_ptr _M_node; - }; + }; template<typename _Val> inline bool @@ -325,7 +325,7 @@ namespace std 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; @@ -505,27 +505,27 @@ namespace std 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(); @@ -539,7 +539,8 @@ namespace std _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); @@ -722,14 +723,14 @@ namespace std 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> @@ -1205,14 +1206,14 @@ namespace std 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, @@ -1223,37 +1224,37 @@ namespace std 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 |