Immutable type representing a range of ordered values using upper and lower bounds. Some useful methods:
Contains(T value)
- true if value is within the rangePrecedes(T value)
- true if value > upper bound of rangeSucceeds(T value)
- true if value < lower bound of rangeSucceeds(Range<T> other)
Precedes(Range<T> other)
Overlaps(Range<T> other)
Intersect(Range<T> other)
- get the overlapping range, throw if no overlapUnion(Range<T> other)
- combine overlapping ranges, throw if no overlapvar reservations = new List<Range<DateTime>>();
reservations.Add(new Range(DateTime.Now, DateTime.Now.AddHours(1)));
var conflicts = reservations.Where(r => r.Overlaps(candidate));