41 #ifdef PB_DS_CLASS_C_DEC
44 typename PB_DS_CLASS_C_DEC::node_allocator
45 PB_DS_CLASS_C_DEC::s_node_allocator;
49 PB_DS_BIN_TREE_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
52 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
57 PB_DS_BIN_TREE_NAME(
const Cmp_Fn& r_cmp_fn) :
58 Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0)
61 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
66 PB_DS_BIN_TREE_NAME(
const Cmp_Fn& r_cmp_fn,
const node_update& r_node_update) :
68 node_update(r_node_update),
69 m_p_head(s_node_allocator.allocate(1)),
73 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
78 PB_DS_BIN_TREE_NAME(
const PB_DS_CLASS_C_DEC& other) :
82 #ifdef PB_DS_TREE_TRACE
83 PB_DS_TREE_TRACE_BASE_C_DEC(other),
87 m_p_head(s_node_allocator.allocate(1)),
91 m_size = other.m_size;
92 PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
96 m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent);
97 if (m_p_head->m_p_parent != 0)
98 m_p_head->m_p_parent->m_p_parent = m_p_head;
99 m_size = other.m_size;
100 initialize_min_max();
104 _GLIBCXX_DEBUG_ONLY(debug_base::clear();)
105 s_node_allocator.deallocate(m_p_head, 1);
106 __throw_exception_again;
108 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
114 swap(PB_DS_CLASS_C_DEC& other)
116 PB_DS_STRUCT_ONLY_ASSERT_VALID((*
this))
117 PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
119 std::
swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
120 PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
121 PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
127 value_swap(PB_DS_CLASS_C_DEC& other)
129 _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
136 ~PB_DS_BIN_TREE_NAME()
139 s_node_allocator.deallocate(m_p_head, 1);
147 m_p_head->m_p_parent = 0;
148 m_p_head->m_p_left = m_p_head;
149 m_p_head->m_p_right = m_p_head;
154 typename PB_DS_CLASS_C_DEC::node_pointer
156 recursive_copy_node(
const node_pointer p_nd)
161 node_pointer p_ret = s_node_allocator.allocate(1);
164 new (p_ret) node(*p_nd);
168 s_node_allocator.deallocate(p_ret, 1);
169 __throw_exception_again;
172 p_ret->m_p_left = p_ret->m_p_right = 0;
176 p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left);
177 p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right);
182 __throw_exception_again;
185 if (p_ret->m_p_left != 0)
186 p_ret->m_p_left->m_p_parent = p_ret;
188 if (p_ret->m_p_right != 0)
189 p_ret->m_p_right->m_p_parent = p_ret;
191 PB_DS_ASSERT_NODE_CONSISTENT(p_ret)
200 if (m_p_head->m_p_parent == 0)
202 m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
207 node_pointer p_min = m_p_head->m_p_parent;
208 while (p_min->m_p_left != 0)
209 p_min = p_min->m_p_left;
210 m_p_head->m_p_left = p_min;
214 node_pointer p_max = m_p_head->m_p_parent;
215 while (p_max->m_p_right != 0)
216 p_max = p_max->m_p_right;
217 m_p_head->m_p_right = p_max;
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
void swap(shared_lock< _Mutex > &__x, shared_lock< _Mutex > &__y) noexcept
Swap specialization for shared_lock.
ISO C++ entities toplevel namespace is std.