42 inline typename PB_DS_CLASS_C_DEC::point_iterator
44 push(const_reference r_val)
46 PB_DS_ASSERT_VALID_COND((*
this),
true)
47 node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
50 PB_DS_ASSERT_VALID_COND((*this),true)
51 return point_iterator(p_nd);
57 insert_node(node_pointer p_nd)
59 if (base_type::m_p_root == 0)
61 p_nd->m_p_next_sibling = 0;
62 p_nd->m_p_prev_or_parent = 0;
63 p_nd->m_p_l_child = 0;
65 base_type::m_p_root = p_nd;
69 if (base_type::m_p_root->m_metadata > 0)
71 p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
72 p_nd->m_p_next_sibling = base_type::m_p_root;
73 base_type::m_p_root->m_p_prev_or_parent = p_nd;
74 base_type::m_p_root = p_nd;
79 if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
81 p_nd->m_p_next_sibling = base_type::m_p_root->m_p_next_sibling;
82 p_nd->m_p_prev_or_parent = 0;
84 p_nd->m_p_l_child = base_type::m_p_root;
85 base_type::m_p_root->m_p_prev_or_parent = p_nd;
86 base_type::m_p_root->m_p_next_sibling = 0;
87 base_type::m_p_root = p_nd;
91 p_nd->m_p_next_sibling = 0;
92 p_nd->m_p_l_child = 0;
93 p_nd->m_p_prev_or_parent = base_type::m_p_root;
95 _GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0);
96 base_type::m_p_root->m_p_l_child = p_nd;
97 base_type::m_p_root->m_metadata = 1;
100 base_type::m_p_root = fix(base_type::m_p_root);
104 inline typename PB_DS_CLASS_C_DEC::node_pointer
106 fix(node_pointer p_nd)
const
108 while (p_nd->m_p_next_sibling != 0 &&
109 p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata)
111 node_pointer p_next = p_nd->m_p_next_sibling;
112 if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
114 p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
116 if (p_nd->m_p_prev_or_parent != 0)
117 p_nd->m_p_prev_or_parent->m_p_next_sibling = p_next;
119 base_type::make_child_of(p_nd, p_next);
120 ++p_next->m_metadata;
125 p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
127 if (p_nd->m_p_next_sibling != 0)
128 p_next->m_p_next_sibling = 0;
130 base_type::make_child_of(p_next, p_nd);
135 if (p_nd->m_p_next_sibling != 0)
136 p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
144 modify(point_iterator it, const_reference r_new_val)
146 PB_DS_ASSERT_VALID_COND((*
this),
true)
147 node_pointer p_nd = it.m_p_nd;
149 _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
150 PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false)
152 const
bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
153 p_nd->m_value = r_new_val;
157 node_pointer p_parent = base_type::parent(p_nd);
158 while (p_parent != 0 &&
159 Cmp_Fn::operator()(p_parent->m_value, p_nd->m_value))
161 base_type::swap_with_parent(p_nd, p_parent);
162 p_parent = base_type::parent(p_nd);
165 if (p_nd->m_p_prev_or_parent == 0)
166 base_type::m_p_root = p_nd;
169 PB_DS_ASSERT_VALID_COND((*
this),
true)
173 base_type::bubble_to_top(p_nd);
174 remove_parentless_node(p_nd);
177 PB_DS_ASSERT_VALID_COND((*this),true)