Exemplo n.º 1
0
        public object insert(object T)
        {
            int           res = 1;
            TGlsBTreeNode p   = root;
            TGlsBTreeNode n   = root.rchild;

            while (n != null)
            {
                p   = n;
                res = cmp(T, p.Val);
                if (res <= 0)
                {
                    n = p.lchild;
                }
                else
                {
                    n = p.rchild;
                }
            }
            win = new TGlsBTreeNode(T);
            if (res <= 0)
            {
                p.lchild = win;
                p.Prev.insert(win);
            }
            else
            {
                p.rchild = win;
                p.insert(win);
            }
            return(T);
        }
Exemplo n.º 2
0
 public TGlsBTreeNode(object T)
 {
     base.TGlsNode1();
     _val    = T;
     _lchild = null;
     _rchild = null;
     bIsRoot = true;
 }
Exemplo n.º 3
0
        /*         public bool isEmpty();
         *       public void* find(void* T);
         *       public void* findMin();
         *       public void* findMax();*/
        public void inorder(acp acpp)
        {
            TGlsBTreeNode n = (TGlsBTreeNode)(root.Next);

            while (n != root)
            {
                if (!(acpp(n.Val)))
                {
                    break;
                }
                n = (TGlsBTreeNode)(n.Next);
            }
        }
Exemplo n.º 4
0
 /*  TGlsBTreeNode _findMin(TGlsBTreeNode n);
  * TGlsBTreeNode _findMax(TGlsBTreeNode n);*/
 public TGlsBinaryTree(TCmp ACmp)
 {
     cmp = ACmp;
     win = root = new TGlsBTreeNode(null);
 }