Commit b4c70e89 by Gawain Bolton Committed by Benjamin Kosnik

re PR libstdc++/11504 (-Wcast-qual vs. stl_tree)


2003-07-30  Gawain Bolton  <gp.bolton@computer.org>

	PR libstdc++/11504.
	* include/bits/stl_tree.h: Replace C-style casts with C++-style
	casts.  Changes to avoid casting away constness.  Eliminate
	_Rb_tree_base_iterator class.  Change _Rb_tree_iterator to use
	initialization lists.  Move out implementation of __black_count()
	to...
        * src/stl_tree.cc: ...here and rename _Rb_tree_black_count().
        Rename_Rb_tree_base_iterator::_M_increment() to
        _Rb_tree_increment and _Rb_tree_base_iterator::_M_decrement() to
        _Rb_tree_decrement.
        * config/linker-map.gnu: Add and change symbols here.

From-SVN: r69958
parent cf68fdb1
2003-07-30 Gawain Bolton <gp.bolton@computer.org>
PR libstdc++/11504.
* include/bits/stl_tree.h: Replace C-style casts with C++-style
casts. Changes to avoid casting away constness. Eliminate
_Rb_tree_base_iterator class. Change _Rb_tree_iterator to use
initialization lists. Move out implementation of __black_count()
to...
* src/stl_tree.cc: ...here and rename _Rb_tree_black_count().
Rename_Rb_tree_base_iterator::_M_increment() to
_Rb_tree_increment and _Rb_tree_base_iterator::_M_decrement() to
_Rb_tree_decrement.
* config/linker-map.gnu: Add and change symbols here.
2003-07-30 Jonathan Wakely <redi@gcc.gnu.org>
* docs/html/22_locale/howto.html: Use locale::classic() instead
......
......@@ -76,9 +76,10 @@ GLIBCXX_3.4 {
_ZSt9has_facet*;
# _Rb_tree
_ZNSt22_Rb_tree_base_iterator12_M_decrementEv;
_ZNSt22_Rb_tree_base_iterator12_M_incrementEv;
_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base;
_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base;
_ZSt18_Rb_tree_rebalancePSt18_Rb_tree_node_baseRS0_;
_ZSt20_Rb_tree_black_countPKSt18_Rb_tree_node_baseS1_;
_ZSt20_Rb_tree_rotate_leftPSt18_Rb_tree_node_baseRS0_;
_ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_;
_ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_;
......
......@@ -59,51 +59,53 @@
namespace std
{
void
_Rb_tree_base_iterator::_M_increment()
_Rb_tree_node_base*
_Rb_tree_increment(_Rb_tree_node_base* __x)
{
if (_M_node->_M_right != 0)
if (__x->_M_right != 0)
{
_M_node = _M_node->_M_right;
while (_M_node->_M_left != 0)
_M_node = _M_node->_M_left;
__x = __x->_M_right;
while (__x->_M_left != 0)
__x = __x->_M_left;
}
else
{
_Base_ptr __y = _M_node->_M_parent;
while (_M_node == __y->_M_right)
_Rb_tree_node_base* __y = __x->_M_parent;
while (__x == __y->_M_right)
{
_M_node = __y;
__x = __y;
__y = __y->_M_parent;
}
if (_M_node->_M_right != __y)
_M_node = __y;
if (__x->_M_right != __y)
__x = __y;
}
return __x;
}
void
_Rb_tree_base_iterator::_M_decrement()
_Rb_tree_node_base*
_Rb_tree_decrement(_Rb_tree_node_base* __x)
{
if (_M_node->_M_color == _S_red
&& _M_node->_M_parent->_M_parent == _M_node)
_M_node = _M_node->_M_right;
else if (_M_node->_M_left != 0)
if (__x->_M_color == _S_red
&& __x->_M_parent->_M_parent == __x)
__x = __x->_M_right;
else if (__x->_M_left != 0)
{
_Base_ptr __y = _M_node->_M_left;
_Rb_tree_node_base* __y = __x->_M_left;
while (__y->_M_right != 0)
__y = __y->_M_right;
_M_node = __y;
__x = __y;
}
else
{
_Base_ptr __y = _M_node->_M_parent;
while (_M_node == __y->_M_left)
_Rb_tree_node_base* __y = __x->_M_parent;
while (__x == __y->_M_left)
{
_M_node = __y;
__x = __y;
__y = __y->_M_parent;
}
_M_node = __y;
__x = __y;
}
return __x;
}
void
......@@ -362,4 +364,23 @@ namespace std
}
return __y;
}
unsigned int
_Rb_tree_black_count(const _Rb_tree_node_base* __node,
const _Rb_tree_node_base* __root)
{
if (__node == 0)
return 0;
unsigned int __sum = 0;
do
{
if (__node->_M_color == _S_black)
++__sum;
if (__node == __root)
break;
__node = __node->_M_parent;
}
while (1);
return __sum;
}
} // namespace std
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment