44 insert(const_reference r_value)
46 PB_DS_ASSERT_VALID((*
this))
47 std::pair<point_iterator,
bool> ins_pair = base_type::insert_leaf(r_value);
48 if (ins_pair.second == true)
50 ins_pair.first.m_p_nd->m_red =
true;
51 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
52 insert_fixup(ins_pair.first.m_p_nd);
55 PB_DS_ASSERT_VALID((*this))
62 insert_fixup(node_pointer p_nd)
64 _GLIBCXX_DEBUG_ASSERT(p_nd->m_red ==
true);
65 while (p_nd != base_type::m_p_head->m_p_parent && p_nd->m_p_parent->m_red)
67 if (p_nd->m_p_parent == p_nd->m_p_parent->m_p_parent->m_p_left)
69 node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_right;
70 if (p_y != 0 && p_y->m_red)
72 p_nd->m_p_parent->m_red =
false;
74 p_nd->m_p_parent->m_p_parent->m_red =
true;
75 p_nd = p_nd->m_p_parent->m_p_parent;
79 if (p_nd == p_nd->m_p_parent->m_p_right)
81 p_nd = p_nd->m_p_parent;
82 base_type::rotate_left(p_nd);
84 p_nd->m_p_parent->m_red =
false;
85 p_nd->m_p_parent->m_p_parent->m_red =
true;
86 base_type::rotate_right(p_nd->m_p_parent->m_p_parent);
91 node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_left;
92 if (p_y != 0 && p_y->m_red)
94 p_nd->m_p_parent->m_red =
false;
96 p_nd->m_p_parent->m_p_parent->m_red =
true;
97 p_nd = p_nd->m_p_parent->m_p_parent;
101 if (p_nd == p_nd->m_p_parent->m_p_left)
103 p_nd = p_nd->m_p_parent;
104 base_type::rotate_right(p_nd);
106 p_nd->m_p_parent->m_red =
false;
107 p_nd->m_p_parent->m_p_parent->m_red =
true;
108 base_type::rotate_left(p_nd->m_p_parent->m_p_parent);
113 base_type::update_to_top(p_nd, (node_update* )
this);
114 base_type::m_p_head->m_p_parent->m_red =
false;
ISO C++ entities toplevel namespace is std.
Struct holding two objects of arbitrary type.