private void AddToSlot(ref IntervalCollection slot, Interval interval) { if (slot == null) { slot = new IntervalCollection(); } slot.AddUnique(interval); }
internal int AddUnique(Interval interval) { int index = this.IndexOf(interval); if (-1 == index) { return this.Add(interval); } return index; }
private void EditRight(Interval interval, bool add) { double num; if (add) { this.EnsureRoot(interval.UpperBound); } IntervalBoundary root = this.root; IntervalBoundary boundary2 = null; Label_0018: num = root.Value; if (num > interval.UpperBound) { root = add ? root.EnsureLeft(interval.UpperBound) : root.Left; goto Label_0018; } if ((boundary2 != null) && (boundary2.Value >= interval.LowerBound)) { if (add) { root.AddToLtSlot(interval); } else { root.RemoveFromLtSlot(interval); } } if (num < interval.UpperBound) { if (num > interval.LowerBound) { if (add) { root.AddToEqSlot(interval); } else { root.RemoveFromEqSlot(interval); } } boundary2 = root; root = add ? root.EnsureRight(interval.UpperBound) : root.Right; goto Label_0018; } if (IntervalOp.LessThanEquals == interval.UpperOp) { if (add) { root.AddToEqSlot(interval); } else { root.RemoveFromEqSlot(interval); } } }
private void RemoveFromSlot(ref IntervalCollection slot, Interval interval) { if (slot != null) { slot.Remove(interval); if (!slot.HasIntervals) { slot = null; } } }
internal void RemoveFromLtSlot(Interval interval) { this.RemoveFromSlot(ref this.ltSlot, interval); }
internal void RemoveFromLtSlot(Interval interval) { Fx.Assert(null != interval, ""); this.RemoveFromSlot(ref this.ltSlot, interval); }
internal int IndexOf(Interval interval) { Fx.Assert(null != interval, ""); return(base.IndexOf(interval)); }
void RemoveFromSlot(ref IntervalCollection slot, Interval interval) { if (null != slot) { slot.Remove(interval); if (!slot.HasIntervals) { slot = null; } } }
void AddIntervalToTree(Interval interval) { this.EditLeft(interval, true); this.EditRight(interval, true); }
internal void Remove(Interval interval) { Fx.Assert(null != interval, ""); base.Remove(interval); this.TrimToSize(); }
void AddToSlot(ref IntervalCollection slot, Interval interval) { if (null == slot) { slot = new IntervalCollection(); } slot.AddUnique(interval); }
private void PruneTree(Interval intervalRemoved) { if (-1 == this.intervals.IndexOf(intervalRemoved.LowerBound)) { this.RemoveBoundary(this.FindBoundaryNode(intervalRemoved.LowerBound)); } if ((intervalRemoved.LowerBound != intervalRemoved.UpperBound) && (-1 == this.intervals.IndexOf(intervalRemoved.UpperBound))) { this.RemoveBoundary(this.FindBoundaryNode(intervalRemoved.UpperBound)); } }
internal void Remove(Interval interval) { this.RemoveIntervalFromTree(interval); this.intervals.Remove(interval); this.PruneTree(interval); }
void RemoveIntervalFromTree(Interval interval) { this.EditLeft(interval, false); this.EditRight(interval, false); }
internal void Add(Interval interval) { this.AddIntervalToTree(interval); this.EnsureIntervals(); this.intervals.Add(interval); }
internal Interval FindInterval(Interval interval) { return(this.FindInterval(interval.LowerBound, interval.LowerOp, interval.UpperBound, interval.UpperOp)); }
void EditRight(Interval interval, bool add) { if (add) { this.EnsureRoot(interval.UpperBound); } IntervalBoundary root = this.root; IntervalBoundary rightAncestor = null; while (true) { double rootVal = root.Value; if (rootVal > interval.UpperBound) { // root is outside the interval range because it is > the upper bound root = add ? root.EnsureLeft(interval.UpperBound) : root.Left; continue; } // rootVal is <= to interval.UpperBound // // All values in the subtree at 'root' are > leftAncestor.Value // All values to the right of this node cannot be in the interval because they are > the interval's // upper bound. // Values to the left of this node lie in range (rightAncestor.Value to root.Value) // Thus, the entire left subtree of root will be inside the range if the interval.lowerBound // is <= rightAncestor.Value if (null != rightAncestor && rightAncestor.Value >= interval.LowerBound) { if (add) { root.AddToLtSlot(interval); } else { root.RemoveFromLtSlot(interval); } } if (rootVal < interval.UpperBound) { // This node itself lies in the range if it is also > the lower bound if (rootVal > interval.LowerBound) { if (add) { root.AddToEqSlot(interval); } else { root.RemoveFromEqSlot(interval); } } rightAncestor = root; root = add ? root.EnsureRight(interval.UpperBound) : root.Right; continue; } // upperBound == rootVal. We're done. // If upperBound == lowerBound, we already inserted this when doing AddLeft if (IntervalOp.LessThanEquals == interval.UpperOp) { // If the range is inclusive of the upper bound, then since this node == upperBound, // it must be in the range. if (add) { root.AddToEqSlot(interval); } else { root.RemoveFromEqSlot(interval); } } break; } }
internal int Add(Interval interval) { Fx.Assert(null != interval, ""); this.Capacity = this.Count + 1; return(base.Add(interval)); }
internal int IndexOf(Interval interval) { Fx.Assert(null != interval, ""); return base.IndexOf(interval); }
internal int Add(Interval interval) { this.Capacity = this.Count + 1; return base.Add(interval); }
internal void AddToLtSlot(Interval interval) { Fx.Assert(null != interval, ""); this.AddToSlot(ref this.ltSlot, interval); }
internal Interval FindInterval(Interval interval) { return this.FindInterval(interval.LowerBound, interval.LowerOp, interval.UpperBound, interval.UpperOp); }
internal void Remove(Interval interval) { Fx.Assert(null != interval, ""); Fx.Assert(null != this.intervals, ""); // First, delete all occurences of interval in the tree. Note: we do a reference equals this.RemoveIntervalFromTree(interval); // Remove interval from interval collection this.intervals.Remove(interval); // It may be possible to prune the tree.. this will do the necessary, if required this.PruneTree(interval); }
internal void Add(Interval interval) { Fx.Assert(null != interval, ""); this.AddIntervalToTree(interval); this.EnsureIntervals(); this.intervals.Add(interval); }
internal void AddToEqSlot(Interval interval) { this.AddToSlot(ref this.eqSlot, interval); }
/// <summary> /// An interval has been removed. Prune the tree appropriately /// </summary> /// <param name="intervalRemoved">interval that was removed</param> void PruneTree(Interval intervalRemoved) { // Delete endpoints if no other intervals have them int index; if (-1 == (index = this.intervals.IndexOf(intervalRemoved.LowerBound))) { this.RemoveBoundary(this.FindBoundaryNode(intervalRemoved.LowerBound)); } if (intervalRemoved.LowerBound != intervalRemoved.UpperBound && -1 == (index = this.intervals.IndexOf(intervalRemoved.UpperBound))) { this.RemoveBoundary(this.FindBoundaryNode(intervalRemoved.UpperBound)); } }
internal int IndexOf(Interval interval) { return base.IndexOf(interval); }
internal void Remove(Interval interval) { base.Remove(interval); this.TrimToSize(); }
internal void AddToLtSlot(Interval interval) { this.AddToSlot(ref this.ltSlot, interval); }
internal bool Equals(Interval interval) { Fx.Assert(null != interval, ""); return this.Equals(interval.lowerBound, interval.lowerOp, interval.upperBound, interval.upperOp); }
internal void RemoveFromEqSlot(Interval interval) { this.RemoveFromSlot(ref this.eqSlot, interval); }
internal int Add(Interval interval) { Fx.Assert(null != interval, ""); this.Capacity = this.Count + 1; return base.Add(interval); }
internal int AddUnique(Interval interval) { Fx.Assert(null != interval, ""); int index = this.IndexOf(interval); if (-1 == index) { return this.Add(interval); } return index; }
internal bool Equals(Interval interval) { Fx.Assert(null != interval, ""); return(this.Equals(interval.lowerBound, interval.lowerOp, interval.upperBound, interval.upperOp)); }