Ejemplo n.º 1
0
 public override void Remove()
 {
     if (parent == null)
     {
         return;
     }
     parent.childrenList.Remove(this);
     if (depth + 1 == parent.depth)
     {
         parent.UpdateDepth();
     }
     parent.count -= count;
     parent.BubbleCount(-count);
     parent = null;
 }
Ejemplo n.º 2
0
        protected LinkedTree <T> Clone(int level)
        {
            LinkedTree <T> cloneTree = new LinkedTree <T>(Value);

            cloneTree.depth = depth;
            cloneTree.level = level;
            cloneTree.count = count;
            foreach (LinkedTree <T> child in childrenList)
            {
                LinkedTree <T> cloneChild = child.Clone(level + 1);
                cloneChild.parent = cloneTree;
                cloneTree.childrenList.AddLast(cloneChild);
            }
            return(cloneTree);
        }
Ejemplo n.º 3
0
        public override void Add(TreeNode <T> tree)
        {
            LinkedTree <T> gtree = (LinkedTree <T>)tree;

            if (gtree.Parent != null)
            {
                gtree.Remove();
            }
            gtree.parent = this;
            if (gtree.depth + 1 > depth)
            {
                depth = gtree.depth + 1;
                BubbleDepth();
            }
            gtree.level = level + 1;
            gtree.UpdateLevel();
            childrenList.AddLast(gtree);
            count += tree.Count;
            BubbleCount(tree.Count);
        }