42 template<
typename Pred>
45 split(Pred pred, PB_DS_CLASS_C_DEC& other)
47 PB_DS_ASSERT_VALID((*
this))
48 PB_DS_ASSERT_VALID(other)
52 if (base_type::empty())
54 PB_DS_ASSERT_VALID((*
this))
55 PB_DS_ASSERT_VALID(other)
59 base_type::to_linked_list();
60 node_pointer p_out = base_type::prune(pred);
63 _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_next_sibling = p_out->m_p_prev_or_parent = 0;
69 other.push_imp(p_out);
73 PB_DS_ASSERT_VALID(other)
74 node_pointer p_cur = base_type::m_p_root;
75 base_type::m_p_root = 0;
78 node_pointer p_next = p_cur->m_p_next_sibling;
79 p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0;
85 PB_DS_ASSERT_VALID((*
this))
86 PB_DS_ASSERT_VALID(other)
92 join(PB_DS_CLASS_C_DEC& other)
94 PB_DS_ASSERT_VALID((*
this))
95 PB_DS_ASSERT_VALID(other)
97 if (other.m_p_root == 0)
99 PB_DS_ASSERT_VALID((*
this))
100 PB_DS_ASSERT_VALID(other)
104 if (base_type::m_p_root == 0)
105 base_type::m_p_root = other.m_p_root;
106 else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value))
108 base_type::make_child_of(base_type::m_p_root, other.m_p_root);
109 PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root,
false)
110 base_type::m_p_root = other.m_p_root;
114 base_type::make_child_of(other.m_p_root, base_type::m_p_root);
115 PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root,
false)
118 base_type::m_size += other.m_size;
121 PB_DS_ASSERT_VALID((*
this))
122 PB_DS_ASSERT_VALID(other)