41#ifdef PB_DS_CLASS_C_DEC
46insert_leaf(const_reference r_value)
48 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
51 return
std::make_pair(insert_imp_empty(r_value),
54 node_pointer p_nd = m_p_head->m_p_parent;
55 node_pointer p_pot = m_p_head;
58 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
63 p_nd = p_nd->m_p_left;
66 p_nd = p_nd->m_p_right;
68 if (p_pot == m_p_head)
69 return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right,
false),
72 if (!Cmp_Fn::operator()(PB_DS_V2F(r_value),
73 PB_DS_V2F(p_pot->m_value)))
75 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
76 PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value))
77 return
std::make_pair(p_pot, false);
80 PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
82 p_nd = p_pot->m_p_left;
84 return
std::make_pair(insert_leaf_new(r_value, p_pot, true),
87 while (p_nd->m_p_right != 0)
88 p_nd = p_nd->m_p_right;
90 return
std::make_pair(insert_leaf_new(r_value, p_nd, false),
95inline typename PB_DS_CLASS_C_DEC::iterator
97insert_leaf_new(const_reference r_value, node_pointer p_nd,
bool left_nd)
99 node_pointer p_new_nd =
100 get_new_node_for_leaf_insert(r_value,
101 traits_base::m_no_throw_copies_indicator);
105 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == 0);
106 _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(r_value),
107 PB_DS_V2F(p_nd->m_value)));
109 p_nd->m_p_left = p_new_nd;
110 if (m_p_head->m_p_left == p_nd)
111 m_p_head->m_p_left = p_new_nd;
115 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == 0);
116 _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
117 PB_DS_V2F(r_value)));
119 p_nd->m_p_right = p_new_nd;
120 if (m_p_head->m_p_right == p_nd)
121 m_p_head->m_p_right = p_new_nd;
124 p_new_nd->m_p_parent = p_nd;
125 p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
126 PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
128 update_to_top(p_new_nd, (node_update* )
this);
129 _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
130 return iterator(p_new_nd);
134inline typename PB_DS_CLASS_C_DEC::iterator
136insert_imp_empty(const_reference r_value)
138 node_pointer p_new_node =
139 get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator);
141 m_p_head->m_p_left = m_p_head->m_p_right =
142 m_p_head->m_p_parent = p_new_node;
144 p_new_node->m_p_parent = m_p_head;
145 p_new_node->m_p_left = p_new_node->m_p_right = 0;
146 _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
148 update_to_top(m_p_head->m_p_parent, (node_update*)
this);
149 return iterator(p_new_node);
153inline typename PB_DS_CLASS_C_DEC::node_pointer
155get_new_node_for_leaf_insert(const_reference r_val, false_type)
157 node_pointer p_new_nd = s_node_allocator.allocate(1);
158 cond_dealtor_t cond(p_new_nd);
160 new (
const_cast<void*
>(
static_cast<const void*
>(&p_new_nd->m_value)))
161 typename node::value_type(r_val);
163 cond.set_no_action();
164 p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
170inline typename PB_DS_CLASS_C_DEC::node_pointer
172get_new_node_for_leaf_insert(const_reference r_val, true_type)
174 node_pointer p_new_nd = s_node_allocator.allocate(1);
176 new (
const_cast<void*
>(
static_cast<const void*
>(&p_new_nd->m_value)))
177 typename node::value_type(r_val);
179 p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
ISO C++ entities toplevel namespace is std.
Struct holding two objects of arbitrary type.