コード例 #1
0
ファイル: SegmentTree.cs プロジェクト: xiluoyouqd/monodevelop
        public bool Remove(TreeSegment node)
        {
            if (node.segmentTree == null)
            {
                return(false);
            }
            if (node.segmentTree != this)
            {
                throw new InvalidOperationException("Tried to remove tree segment from wrong tree.");
            }
            var calculatedOffset = node.Offset;
            var next             = node.GetNextNode();

            if (next != null)
            {
                next.DistanceToPrevNode += node.DistanceToPrevNode;
            }
            tree.Remove(node);
            if (next != null)
            {
                next.UpdateAugmentedData();
            }
            node.segmentTree        = null;
            node.parent             = node.left = node.right = null;
            node.DistanceToPrevNode = calculatedOffset;
            return(true);
        }
コード例 #2
0
        public void Remove(TreeSegment node)
        {
            var calculatedOffset = node.Offset;
            var next             = node.GetNextNode();

            if (next != null)
            {
                next.DistanceToPrevNode += node.DistanceToPrevNode;
            }
            tree.Remove(node);
            if (next != null)
            {
                next.UpdateAugmentedData();
            }
            node.segmentTree        = null;
            node.parent             = node.left = node.right = null;
            node.DistanceToPrevNode = calculatedOffset;
        }