44 insert_leaf(const_reference r_value)
46 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
52 node_pointer p_nd = m_p_head->m_p_parent;
53 node_pointer p_pot = m_p_head;
56 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
61 p_nd = p_nd->m_p_left;
64 p_nd = p_nd->m_p_right;
66 if (p_pot == m_p_head)
67 return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right,
false),
70 if (!Cmp_Fn::operator()(PB_DS_V2F(r_value),
71 PB_DS_V2F(p_pot->m_value)))
73 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
74 PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value))
78 PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
80 p_nd = p_pot->m_p_left;
82 return
std::
make_pair(insert_leaf_new(r_value, p_pot, true),
85 while (p_nd->m_p_right != 0)
86 p_nd = p_nd->m_p_right;
88 return
std::
make_pair(insert_leaf_new(r_value, p_nd, false),
93 inline typename PB_DS_CLASS_C_DEC::iterator
95 insert_leaf_new(const_reference r_value, node_pointer p_nd,
bool left_nd)
97 node_pointer p_new_nd =
98 get_new_node_for_leaf_insert(r_value,
99 traits_base::m_no_throw_copies_indicator);
103 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == 0);
104 _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(r_value),
105 PB_DS_V2F(p_nd->m_value)));
107 p_nd->m_p_left = p_new_nd;
108 if (m_p_head->m_p_left == p_nd)
109 m_p_head->m_p_left = p_new_nd;
113 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == 0);
114 _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
115 PB_DS_V2F(r_value)));
117 p_nd->m_p_right = p_new_nd;
118 if (m_p_head->m_p_right == p_nd)
119 m_p_head->m_p_right = p_new_nd;
122 p_new_nd->m_p_parent = p_nd;
123 p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
124 PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
126 update_to_top(p_new_nd, (node_update* )this);
127 _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
128 return iterator(p_new_nd);
132 inline typename PB_DS_CLASS_C_DEC::iterator
134 insert_imp_empty(const_reference r_value)
136 node_pointer p_new_node =
137 get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator);
139 m_p_head->m_p_left = m_p_head->m_p_right =
140 m_p_head->m_p_parent = p_new_node;
142 p_new_node->m_p_parent = m_p_head;
143 p_new_node->m_p_left = p_new_node->m_p_right = 0;
144 _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
146 update_to_top(m_p_head->m_p_parent, (node_update*)
this);
147 return iterator(p_new_node);
151 inline typename PB_DS_CLASS_C_DEC::node_pointer
153 get_new_node_for_leaf_insert(const_reference r_val,
false_type)
155 node_pointer p_new_nd = s_node_allocator.allocate(1);
156 cond_dealtor_t cond(p_new_nd);
158 new (
const_cast<void*
>(
static_cast<const void*
>(&p_new_nd->m_value)))
159 typename node::value_type(r_val);
161 cond.set_no_action();
162 p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
168 inline typename PB_DS_CLASS_C_DEC::node_pointer
170 get_new_node_for_leaf_insert(const_reference r_val,
true_type)
172 node_pointer p_new_nd = s_node_allocator.allocate(1);
174 new (
const_cast<void*
>(
static_cast<const void*
>(&p_new_nd->m_value)))
175 typename node::value_type(r_val);
177 p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
ISO C++ entities toplevel namespace is std.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
Struct holding two objects of arbitrary type.