41 #ifdef PB_DS_CLASS_C_DEC
44 inline typename PB_DS_CLASS_C_DEC::point_iterator
46 push(const_reference r_val)
48 PB_DS_ASSERT_VALID_COND((*
this),
true)
49 node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
52 PB_DS_ASSERT_VALID_COND((*this),true)
53 return point_iterator(p_nd);
59 insert_node(node_pointer p_nd)
61 if (base_type::m_p_root == 0)
63 p_nd->m_p_next_sibling = 0;
64 p_nd->m_p_prev_or_parent = 0;
65 p_nd->m_p_l_child = 0;
67 base_type::m_p_root = p_nd;
71 if (base_type::m_p_root->m_metadata > 0)
73 p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
74 p_nd->m_p_next_sibling = base_type::m_p_root;
75 base_type::m_p_root->m_p_prev_or_parent = p_nd;
76 base_type::m_p_root = p_nd;
81 if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
83 p_nd->m_p_next_sibling = base_type::m_p_root->m_p_next_sibling;
84 p_nd->m_p_prev_or_parent = 0;
86 p_nd->m_p_l_child = base_type::m_p_root;
87 base_type::m_p_root->m_p_prev_or_parent = p_nd;
88 base_type::m_p_root->m_p_next_sibling = 0;
89 base_type::m_p_root = p_nd;
93 p_nd->m_p_next_sibling = 0;
94 p_nd->m_p_l_child = 0;
95 p_nd->m_p_prev_or_parent = base_type::m_p_root;
97 _GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0);
98 base_type::m_p_root->m_p_l_child = p_nd;
99 base_type::m_p_root->m_metadata = 1;
102 base_type::m_p_root = fix(base_type::m_p_root);
106 inline typename PB_DS_CLASS_C_DEC::node_pointer
108 fix(node_pointer p_nd)
const
110 while (p_nd->m_p_next_sibling != 0 &&
111 p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata)
113 node_pointer p_next = p_nd->m_p_next_sibling;
114 if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
116 p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
118 if (p_nd->m_p_prev_or_parent != 0)
119 p_nd->m_p_prev_or_parent->m_p_next_sibling = p_next;
121 base_type::make_child_of(p_nd, p_next);
122 ++p_next->m_metadata;
127 p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
129 if (p_nd->m_p_next_sibling != 0)
130 p_next->m_p_next_sibling = 0;
132 base_type::make_child_of(p_next, p_nd);
137 if (p_nd->m_p_next_sibling != 0)
138 p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
146 modify(point_iterator it, const_reference r_new_val)
148 PB_DS_ASSERT_VALID_COND((*
this),
true)
149 node_pointer p_nd = it.m_p_nd;
151 _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
152 PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false)
154 const
bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
155 p_nd->m_value = r_new_val;
159 node_pointer p_parent = base_type::parent(p_nd);
160 while (p_parent != 0 &&
161 Cmp_Fn::operator()(p_parent->m_value, p_nd->m_value))
163 base_type::swap_with_parent(p_nd, p_parent);
164 p_parent = base_type::parent(p_nd);
167 if (p_nd->m_p_prev_or_parent == 0)
168 base_type::m_p_root = p_nd;
171 PB_DS_ASSERT_VALID_COND((*
this),
true)
175 base_type::bubble_to_top(p_nd);
176 remove_parentless_node(p_nd);
179 PB_DS_ASSERT_VALID_COND((*this),true)