Library of operations for interval type from Interval Library. There are operations of comparisons for low and upper boundary and for entry interval, operation to check interval on containing point etc.
var openInterval = new Interval<int>(
lowerBound: new OpenLowerBound<int>(0),
upperBound: new OpenUpperBound<int>(10));
openInterval.Contains(
point: 5,
comparer: Comparer<int>.Default) // => true
openInterval.Contains(
point: 11,
comparer: Comparer<int>.Default) // => false
var interval = new Interval.Interval<string>(
lowerBound: new OpenLowerBound<string>("a"),
upperBound: new OpenUpperBound<string>("z"));
interval.Contains(
point: "B",
comparer: StringComparer.Ordinal) // => false
interval.Contains(
point: "B",
comparer: StringComparer.OrdinalIgnoreCase); // => false
new Interval<int>(
lowerBound: new ClosedLowerBound<int>(1),
upperBound: new ClosedUpperBound<int>(2))
.GetBoundariesPoints(); // -> [1,2]
You can compare deferent types of lower or upper boundary
new LowerBoundComparer<int>(
comparer: Comparer<int>.Default)
.Compare(
left: new ClosedLowerBound<int>(10),
right: new ClosedLowerBound<int>(11)); // -> 1
The same for upper boundary
new UpperBoundComparer<int>(
comparer: Comparer<int>.Default)
.Compare(
left: new ClosedUpperBound<int>(10),
right: new ClosedUpperBound<int>(11)); // -> 1
var intervalA = new Interval.Interval<int>(
lowerBound: new ClosedLowerBound<int>(0),
upperBound: new ClosedUpperBound<int>(10));
var intervalB = new Interval.Interval<int>(
lowerBound: new ClosedLowerBound<int>(1),
upperBound: new ClosedUpperBound<int>(9));
new IntervalComparer<int>(
comparer: Comparer<int>.Default)
.Compare(
left: intervalA,
right: intervalB); // -> -1