42 template<
typename Pred>
45 split(Pred pred, PB_DS_CLASS_C_DEC& other)
47 PB_DS_ASSERT_VALID_COND((*
this),
true)
48 PB_DS_ASSERT_VALID_COND(other,true)
51 if (base_type::empty())
53 PB_DS_ASSERT_VALID_COND((*
this),
true)
54 PB_DS_ASSERT_VALID_COND(other,true)
58 base_type::to_linked_list();
59 node_pointer p_out = base_type::prune(pred);
62 _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
66 node_pointer p_next = p_out->m_p_next_sibling;
67 p_out->m_p_l_child = p_out->m_p_prev_or_parent = 0;
68 p_out->m_metadata = 0;
70 p_out->m_p_next_sibling = other.m_p_root;
71 if (other.m_p_root != 0)
72 other.m_p_root->m_p_prev_or_parent = p_out;
74 other.m_p_root = p_out;
75 other.m_p_root = other.fix(other.m_p_root);
79 PB_DS_ASSERT_VALID_COND(other,
true)
80 node_pointer p_cur = base_type::m_p_root;
81 base_type::m_p_root = 0;
85 node_pointer p_next = p_cur->m_p_next_sibling;
86 p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
87 p_cur->m_metadata = 0;
88 p_cur->m_p_next_sibling = base_type::m_p_root;
90 if (base_type::m_p_root != 0)
91 base_type::m_p_root->m_p_prev_or_parent = p_cur;
93 base_type::m_p_root = p_cur;
94 base_type::m_p_root = fix(base_type::m_p_root);
99 PB_DS_ASSERT_VALID_COND((*
this),
true)
100 PB_DS_ASSERT_VALID_COND(other,true)
106 join(PB_DS_CLASS_C_DEC& other)
108 PB_DS_ASSERT_VALID_COND((*
this),
true)
109 PB_DS_ASSERT_VALID_COND(other,true)
111 node_pointer p_other = other.m_p_root;
115 node_pointer p_next = p_other->m_p_next_sibling;
116 std::swap(p_other->m_p_next_sibling, p_other->m_p_prev_or_parent);
119 while (p_other != 0);
121 base_type::m_p_root = join(base_type::m_p_root, other.m_p_root);
122 base_type::m_size += other.m_size;
129 PB_DS_ASSERT_VALID_COND((*
this),
true)
130 PB_DS_ASSERT_VALID_COND(other,true)
134 inline typename PB_DS_CLASS_C_DEC::node_pointer
136 join(node_pointer p_lhs, node_pointer p_rhs)
const
138 node_pointer p_ret = 0;
139 node_pointer p_cur = 0;
141 while (p_lhs != 0 || p_rhs != 0)
146 p_ret = p_cur = p_lhs;
149 p_cur->m_p_next_sibling = p_lhs;
150 p_lhs->m_p_prev_or_parent = p_cur;
154 else if (p_lhs == 0 || p_rhs->m_metadata < p_lhs->m_metadata)
158 p_ret = p_cur = p_rhs;
159 p_rhs = p_rhs->m_p_prev_or_parent;
163 p_cur->m_p_next_sibling = p_rhs;
164 p_rhs = p_rhs->m_p_prev_or_parent;
165 p_cur->m_p_next_sibling->m_p_prev_or_parent = p_cur;
166 p_cur = p_cur->m_p_next_sibling;
169 else if (p_lhs->m_metadata < p_rhs->m_metadata)
172 p_ret = p_cur = p_lhs;
175 p_cur->m_p_next_sibling = p_lhs;
176 p_lhs->m_p_prev_or_parent = p_cur;
177 p_cur = p_cur->m_p_next_sibling;
179 p_lhs = p_cur->m_p_next_sibling;
183 node_pointer p_next_rhs = p_rhs->m_p_prev_or_parent;
184 p_rhs->m_p_next_sibling = p_lhs;
191 p_cur->m_p_next_sibling = 0;
194 p_ret->m_p_prev_or_parent = 0;
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.