Changeset 16592 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval.cs
- Timestamp:
- 02/06/19 16:16:50 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval.cs
r16548 r16592 43 43 public bool Contains(double value) { 44 44 return LowerBound <= value && value <= UpperBound; 45 } 46 47 public bool Contains(Interval other, bool lowerBoundInclusive = true, bool upperBoundInclusive = false) { 48 if (double.IsNegativeInfinity(this.LowerBound) && double.IsPositiveInfinity(this.UpperBound)) 49 return true; 50 //Left-unbounded and right-bounded: 51 if (double.IsNegativeInfinity(this.LowerBound)) { 52 if (upperBoundInclusive) 53 return other.LowerBound <= this.UpperBound && other.UpperBound <= this.UpperBound; 54 return other.LowerBound < this.UpperBound && other.UpperBound < this.UpperBound; 55 } 56 57 //Left-bounded and right-unbounded: 58 if (double.IsPositiveInfinity(this.UpperBound)) { 59 if (lowerBoundInclusive) 60 return other.LowerBound >= this.LowerBound && other.UpperBound >= this.LowerBound; 61 return other.LowerBound > this.LowerBound && other.UpperBound > this.LowerBound; 62 } 63 64 //Proper and bounded: 65 //Closed: 66 if (lowerBoundInclusive && upperBoundInclusive) { 67 return this.LowerBound <= other.LowerBound && other.UpperBound <= this.UpperBound; 68 } 69 70 //Open: 71 if (!lowerBoundInclusive && !upperBoundInclusive) { 72 return this.LowerBound < other.LowerBound && other.UpperBound < this.UpperBound; 73 } 74 75 //Left-closed, right-open: 76 if (lowerBoundInclusive) { 77 return this.LowerBound <= other.LowerBound && other.UpperBound < this.UpperBound; 78 } 79 80 //Left-open, right-closed: 81 return this.LowerBound < other.LowerBound && other.UpperBound <= this.UpperBound; 45 82 } 46 83
Note: See TracChangeset
for help on using the changeset viewer.