示例#1
0
        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;
            }
        }
示例#2
0
 public void MergeWith(IUnionTree <TData> tree)
 {
     MergeRoots(Root, tree.Root);
 }
示例#3
0
 public UnionTree()
 {
     m_Root = this;
 }