private static void MergeRoots(IUnionTree <TData> x, IUnionTree <TData> y) { if (x == y) { return; } if (x.Depth < y.Depth) { x.Root = y; } else if (x.Depth > y.Depth) { y.Root = x; } else { y.Root = x; x.Depth += 1; } }
public void MergeWith(IUnionTree <TData> tree) { MergeRoots(Root, tree.Root); }
public UnionTree() { m_Root = this; }