7 #include "unihashtree.h"
23 UniHashTreeBase::~UniHashTreeBase()
69 while (node != ancestor)
73 assert(node != NULL ||
74 !
"ancestor was not a node in the tree");
97 node = node->_findchild(it());
148 void UniHashTreeBase::_recursive_unsorted_visit(
150 const UniHashTreeBaseVisitor &visitor,
void *userdata,
151 bool preorder,
bool postorder)
154 visitor(a, userdata);
155 Container::Iter i(*
const_cast<Container*
>(a->
xchildren));
156 for (i.rewind(); i.next();)
157 _recursive_unsorted_visit(i.ptr(), visitor, userdata,
158 preorder, postorder);
160 visitor(a, userdata);
163 bool UniHashTreeBase::_recursivecompare(
165 const UniHashTreeBaseComparator &comparator)
174 if (!comparator(a, b))
178 Container::Sorter *ait = NULL, *bit = NULL;
181 ait =
new Container::Sorter(*
const_cast<Container*
>(a->
xchildren),
184 a = ait->next() ? ait->ptr() : NULL;
188 bit =
new Container::Sorter(*
const_cast<Container*
>(b->
xchildren),
191 b = bit->next() ? bit->ptr() : NULL;
195 while (a != NULL && b != NULL)
201 _recursivecompare(a, NULL, comparator);
202 a = ait->next() ? ait->ptr() : NULL;
207 _recursivecompare(NULL, b, comparator);
208 b = bit->next() ? bit->ptr() : NULL;
212 if (!_recursivecompare(a, b, comparator))
214 a = ait->next() ? ait->ptr() : NULL;
215 b = bit->next() ? bit->ptr() : NULL;
223 _recursivecompare(a, NULL, comparator);
224 a = ait->next() ? ait->ptr() : NULL;
229 _recursivecompare(NULL, b, comparator);
230 b = bit->next() ? bit->ptr() : NULL;