Changeset 17370 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs
- Timestamp:
- 11/25/19 13:39:43 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs
r17368 r17370 71 71 } 72 72 73 public bool Contains(Interval other, bool lowerBoundInclusive = true, bool upperBoundInclusive = false) { 74 if (double.IsNegativeInfinity(this.LowerBound) && double.IsPositiveInfinity(this.UpperBound)) 75 return true; 76 //Left-unbounded and right-bounded: 77 if (double.IsNegativeInfinity(this.LowerBound)) { 78 if (upperBoundInclusive) 79 return other.LowerBound <= this.UpperBound && other.UpperBound <= this.UpperBound; 80 return other.LowerBound < this.UpperBound && other.UpperBound < this.UpperBound; 81 } 82 83 //Left-bounded and right-unbounded: 84 if (double.IsPositiveInfinity(this.UpperBound)) { 85 if (lowerBoundInclusive) 86 return other.LowerBound >= this.LowerBound && other.UpperBound >= this.LowerBound; 87 return other.LowerBound > this.LowerBound && other.UpperBound > this.LowerBound; 88 } 89 90 //Proper and bounded: 91 //Closed: 92 if (lowerBoundInclusive && upperBoundInclusive) { 93 return this.LowerBound <= other.LowerBound && other.UpperBound <= this.UpperBound; 94 } 95 96 //Open: 97 if (!lowerBoundInclusive && !upperBoundInclusive) { 98 return this.LowerBound < other.LowerBound && other.UpperBound < this.UpperBound; 99 } 100 101 //Left-closed, right-open: 102 if (lowerBoundInclusive) { 103 return this.LowerBound <= other.LowerBound && other.UpperBound < this.UpperBound; 104 } 105 106 //Left-open, right-closed: 107 return this.LowerBound < other.LowerBound && other.UpperBound <= this.UpperBound; 73 public bool Contains(Interval other) { 74 if (double.IsNegativeInfinity(LowerBound) && double.IsPositiveInfinity(UpperBound)) return true; 75 if (other.LowerBound >= LowerBound && other.UpperBound <= UpperBound) return true; 76 77 return false; 108 78 } 109 79
Note: See TracChangeset
for help on using the changeset viewer.