public static SimpleRange IntersectingRange(iRange raa, iRange rbb) { int interExtent = raa.extent() < rbb.extent() ? raa.extent() : rbb.extent(); int interStart = raa.startP > rbb.startP ? raa.startP : rbb.startP; if (interStart >= interExtent) { return(SimpleRange.theErsatzNullRange()); } return(new SimpleRange(interStart, interExtent - interStart)); }
private void Add(T rangeItem, bool wantOverwrite) { //ranges ordered from low start to high start int insertIndex = 0; for (int i = 0; i < _ranges.Count; ++i) { iRange r = _ranges[i]; //if r is 'beyond' rangeItem //insert at the curr insert index if (rangeItem.startP > r.extent()) { insertIndex++; continue; } if (rangeItem.extent() < r.startP) { break; } OverlapState overlState = rangeItem.overlapStateWith(r); if (OverLapUtil.OverlapExists(overlState)) { //want overwrite?? _ranges.RemoveAt(i); insertIndex = i; // throw new Exception("Discrete Domain Range List doesn't put up with flush or overlapping ranges"); } } this.Insert(insertIndex, rangeItem); }
public OverlapState overlapWithRange(iRange other) { if (this.start == other.extent()) { return(OverlapState.FlushWithStart); } if (this.start > other.extent()) { return(OverlapState.BeforeStart); } if (this.extent() == other.startP) { return(OverlapState.FlushWithExtent); } if (RangesIntersect(this, other)) { if (this.contains(other)) { return(OverlapState.IContainIt); } if (other.contains(this)) { return(OverlapState.ItContainsMe); } if (other.startP < this.startP) { return(OverlapState.OverlappingOverStart); } return(OverlapState.OverlappingOverEnd); } return(OverlapState.BeyondExtent); }
public bool contains(iRange r) { return(this.startP <= r.startP && this.extent() >= r.extent()); }