42 inline typename PB_DS_CLASS_C_DEC::node_pointer
44 get_new_node_for_insert(const_reference r_val)
46 return get_new_node_for_insert(r_val, s_no_throw_copies_ind);
50 inline typename PB_DS_CLASS_C_DEC::node_pointer
52 get_new_node_for_insert(const_reference r_val, false_type)
54 node_pointer p_new_nd = s_node_allocator.allocate(1);
56 cond_dealtor_t cond(p_new_nd);
58 new (
const_cast<void*
>(
59 static_cast<const void*
>(&p_new_nd->m_value)))
60 typename node::value_type(r_val);
70 inline typename PB_DS_CLASS_C_DEC::node_pointer
72 get_new_node_for_insert(const_reference r_val, true_type)
74 node_pointer p_new_nd = s_node_allocator.allocate(1);
76 new (
const_cast<void*
>(
77 static_cast<const void*
>(&p_new_nd->m_value)))
78 typename node::value_type(r_val);
88 make_child_of(node_pointer p_nd, node_pointer p_new_parent)
90 _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
91 _GLIBCXX_DEBUG_ASSERT(p_new_parent != 0);
93 p_nd->m_p_next_sibling = p_new_parent->m_p_l_child;
95 if (p_new_parent->m_p_l_child != 0)
96 p_new_parent->m_p_l_child->m_p_prev_or_parent = p_nd;
98 p_nd->m_p_prev_or_parent = p_new_parent;
100 p_new_parent->m_p_l_child = p_nd;
104 inline typename PB_DS_CLASS_C_DEC::node_pointer
106 parent(node_pointer p_nd)
110 node_pointer p_pot = p_nd->m_p_prev_or_parent;
112 if (p_pot == 0 || p_pot->m_p_l_child == p_nd)
122 swap_with_parent(node_pointer p_nd, node_pointer p_parent)
124 if (p_parent == m_p_root)
127 _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
128 _GLIBCXX_DEBUG_ASSERT(p_parent != 0);
129 _GLIBCXX_DEBUG_ASSERT(parent(p_nd) == p_parent);
131 const bool nd_direct_child = p_parent->m_p_l_child == p_nd;
132 const bool parent_root = p_parent->m_p_prev_or_parent == 0;
133 const bool parent_direct_child =
134 !parent_root&& p_parent->m_p_prev_or_parent->m_p_l_child == p_parent;
136 std::swap(p_parent->m_p_prev_or_parent, p_nd->m_p_prev_or_parent);
137 std::swap(p_parent->m_p_next_sibling, p_nd->m_p_next_sibling);
138 std::swap(p_parent->m_p_l_child, p_nd->m_p_l_child);
139 std::swap(p_parent->m_metadata, p_nd->m_metadata);
141 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child != 0);
142 _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent != 0);
144 if (p_nd->m_p_next_sibling != 0)
145 p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
147 if (p_parent->m_p_next_sibling != 0)
148 p_parent->m_p_next_sibling->m_p_prev_or_parent = p_parent;
150 if (p_parent->m_p_l_child != 0)
151 p_parent->m_p_l_child->m_p_prev_or_parent = p_parent;
153 if (parent_direct_child)
154 p_nd->m_p_prev_or_parent->m_p_l_child = p_nd;
155 else if (!parent_root)
156 p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd;
158 if (!nd_direct_child)
160 p_nd->m_p_l_child->m_p_prev_or_parent = p_nd;
162 p_parent->m_p_prev_or_parent->m_p_next_sibling = p_parent;
166 _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child == p_nd);
167 _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent == p_parent);
169 p_nd->m_p_l_child = p_parent;
170 p_parent->m_p_prev_or_parent = p_nd;
173 _GLIBCXX_DEBUG_ASSERT(parent(p_parent) == p_nd);
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.