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); }
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; }