template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc> _Rb_tree_node<_Value>* _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> ::_M_copy(_Rb_tree_node<_Value>* __x, _Rb_tree_node<_Value>* __p) { // structural copy. __x and __p must be non-null. _Link_type __top = _M_clone_node(__x); __top->_M_parent = __p; _STLP_TRY { if (__x->_M_right) __top->_M_right = _M_copy(_S_right(__x), __top); __p = __top; __x = _S_left(__x); while (__x != 0) { _Link_type __y = _M_clone_node(__x); __p->_M_left = __y; __y->_M_parent = __p; if (__x->_M_right) __y->_M_right = _M_copy(_S_right(__x), __y); __p = __y; __x = _S_left(__x); } } _STLP_UNWIND(_M_erase(__top)); return __top; }
_Rb_tree_node_base* _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::_M_copy(_Rb_tree_node_base* __x, _Rb_tree_node_base* __p) { // structural copy. __x and __p must be non-null. _Base_ptr __top = _M_clone_node(__x); _S_parent(__top) = __p; _STLP_TRY { if (_S_right(__x)) _S_right(__top) = _M_copy(_S_right(__x), __top); __p = __top; __x = _S_left(__x); while (__x != 0) { _Base_ptr __y = _M_clone_node(__x); _S_left(__p) = __y; _S_parent(__y) = __p; if (_S_right(__x)) _S_right(__y) = _M_copy(_S_right(__x), __y); __p = __y; __x = _S_left(__x); } } _STLP_UNWIND(_M_erase(__top)) return __top; }
class _Compare, class _Alloc> _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) { if (this != &__x) { // Note that _Key may be a constant type. clear(); _M_node_count = 0; _M_key_compare = __x._M_key_compare; if (__x._M_root() == 0) { _M_root() = 0; _M_leftmost() = this->_M_header._M_data; _M_rightmost() = this->_M_header._M_data; } else { _M_root() = _M_copy(__x._M_root(), this->_M_header._M_data); _M_leftmost() = _S_minimum(_M_root()); _M_rightmost() = _S_maximum(_M_root()); _M_node_count = __x._M_node_count; } } return *this; }