示例#1
0
            private AVLNode insertOnRight(int indexRelativeToMe, Object obj)
            {
                AVLNode ret = this;

                if (getRightSubTree() == null)
                {
                    setRight(new AVLNode(+1, obj, right, this), null);
                }
                else
                {
                    setRight(right.insert(indexRelativeToMe, obj), null);
                }
                if (relativePosition < 0)
                {
                    relativePosition--;
                }
                ret = balance();
                recalcHeight();
                return(ret);
            }
示例#2
0
            private AVLNode insertOnLeft(int indexRelativeToMe, Object obj)
            {
                AVLNode ret = this;

                if (getLeftSubTree() == null)
                {
                    setLeft(new AVLNode(-1, obj, this, left), null);
                }
                else
                {
                    setLeft(left.insert(indexRelativeToMe, obj), null);
                }

                if (relativePosition >= 0)
                {
                    relativePosition++;
                }
                ret = balance();
                recalcHeight();
                return(ret);
            }