示例#1
0
        public override void Replace(IPersistentStore store, Index index, NodeAVL n)
        {
            NodeAVLDisk node = this;
            RowAVLDisk  row  = this.row;

            if (!row.KeepInMemory(true))
            {
                row  = (RowAVLDisk)store.Get(this.row, true);
                node = (NodeAVLDisk)row.GetNode(this._iId);
            }
            if (node._iParent == -1)
            {
                if (n != null)
                {
                    n = n.SetParent(store, null);
                }
                store.SetAccessor(index, n);
            }
            else
            {
                bool isLeft = node.IsFromLeft(store);
                node.GetParent(store).Set(store, isLeft, n);
            }
            row.KeepInMemory(false);
        }
示例#2
0
        public override NodeAVL SetParent(IPersistentStore store, NodeAVL n)
        {
            NodeAVLDisk node = this;
            RowAVLDisk  row  = this.row;

            if (!row.KeepInMemory(true))
            {
                row  = (RowAVLDisk)store.Get(this.row, true);
                node = (NodeAVLDisk)row.GetNode(this._iId);
            }
            if (!row.IsInMemory())
            {
                row.KeepInMemory(false);
                throw Error.RuntimeError(0xc9, "NodeAVLDisk");
            }
            row.SetNodesChanged();
            node._iParent = (n == null) ? -1 : n.GetPos();
            if ((n != null) && !n.IsInMemory())
            {
                n = this.FindNode(store, n.GetPos());
            }
            node.nParent = n;
            row.KeepInMemory(false);
            return(node);
        }
示例#3
0
        public override bool IsRoot(IPersistentStore store)
        {
            NodeAVLDisk node = this;

            if (!this.row.IsInMemory())
            {
                node = (NodeAVLDisk)((RowAVLDisk)store.Get(this.row, false)).GetNode(this._iId);
            }
            return(node._iParent == -1);
        }
示例#4
0
        public override int GetBalance(IPersistentStore store)
        {
            NodeAVLDisk node = this;

            if (!this.row.IsInMemory())
            {
                node = (NodeAVLDisk)((RowAVLDisk)store.Get(this.row, false)).GetNode(this._iId);
            }
            return(node.IBalance);
        }
示例#5
0
        private NodeAVLDisk FindNode(IPersistentStore store, int pos)
        {
            NodeAVLDisk node  = null;
            RowAVLDisk  disk2 = (RowAVLDisk)store.Get(pos, false);

            if (disk2 != null)
            {
                node = (NodeAVLDisk)disk2.GetNode(this._iId);
            }
            return(node);
        }
示例#6
0
        public override bool IsFromLeft(IPersistentStore store)
        {
            NodeAVLDisk node = this;

            if (!this.row.IsInMemory())
            {
                node = (NodeAVLDisk)((RowAVLDisk)store.Get(this.row, false)).GetNode(this._iId);
            }
            if (node._iParent == -1)
            {
                return(true);
            }
            if ((node.nParent == null) || !node.nParent.IsInMemory())
            {
                node.nParent = this.FindNode(store, this._iParent);
            }
            return(this.GetPos() == ((NodeAVLDisk)node.nParent)._iLeft);
        }
示例#7
0
        public override NodeAVL GetParent(IPersistentStore store)
        {
            NodeAVLDisk node = this;

            if (!this.row.IsInMemory())
            {
                node = (NodeAVLDisk)((RowAVLDisk)store.Get(this.row, false)).GetNode(this._iId);
            }
            if (node._iParent == -1)
            {
                return(null);
            }
            if ((node.nParent == null) || !node.nParent.IsInMemory())
            {
                node.nParent = this.FindNode(store, this._iParent);
            }
            return(node.nParent);
        }
示例#8
0
        public override NodeAVL SetBalance(IPersistentStore store, int b)
        {
            NodeAVLDisk node = this;
            RowAVLDisk  row  = this.row;

            if (!row.KeepInMemory(true))
            {
                row  = (RowAVLDisk)store.Get(this.row, true);
                node = (NodeAVLDisk)row.GetNode(this._iId);
            }
            if (!row.IsInMemory())
            {
                throw Error.RuntimeError(0xc9, "NodeAVLDisk");
            }
            row.SetNodesChanged();
            node.IBalance = b;
            row.KeepInMemory(false);
            return(node);
        }