private static int CompareIntervalsForSort( IntervalInt32 lhs , IntervalInt32 rhs ) { var diff = lhs.min_ - rhs.min_; return(diff == 0 ? (lhs.Equals(rhs) ? 0 : -1) : diff); }
public IntervalInt32[] Split( IntervalInt32 pivot ) { if (!Contains(pivot)) { throw new ArgumentException(); } return(new IntervalInt32[] { new IntervalInt32(min_, pivot.max_) , new IntervalInt32(pivot.min_, max_) }); }
public bool IntersectsWith( IntervalInt32 rhs ) { var result = false; if (min_ < rhs.min_) { result = min_ <= rhs.max_ && max_ >= rhs.min_; } else { result = rhs.min_ <= max_ && rhs.max_ >= min_; } return(result); }
public bool Contains( IntervalInt32 rhs ) { var result = false; if (Length >= rhs.Length) { result = Contains(rhs.min_) && Contains(rhs.max_) ; } else { result = rhs.Contains(min_) && rhs.Contains(max_) ; } return(result); }