static TotalOrder() { var defaultBound = IntervalBound.Open(default(A)).ToOption(); var noBound = Option.Empty <IntervalBound <A> >(); emptyInterval = new Interval <A>(defaultBound, defaultBound, isEmpty: true); unbounedInterval = new Interval <A>(noBound, noBound, isEmpty: false); emptyIntervalSet = new IntervalSet <A>(Enumerable.Empty <Interval <A> >()); }
/// <summary> /// Creates a new interval with the specified bounds. /// </summary> public Interval <A> Interval(IntervalBound <A> lowerBound = null, IntervalBound <A> upperBound = null) { return(Interval(lowerBound.ToOption(), upperBound.ToOption())); }
/// <summary> /// Creates an unbounded interval with closed upper bound. /// </summary> public Interval <A> UnboundedClosedInterval(A upperBound) { return(Interval(upperBound: IntervalBound.Closed(upperBound))); }
/// <summary> /// Creates an unbounded interval with open upper bound. /// </summary> public Interval <A> UnboundedOpenInterval(A upperBound) { return(Interval(upperBound: IntervalBound.Open(upperBound))); }
/// <summary> /// Creates an unbounded interval with closed lower bound. /// </summary> public Interval <A> ClosedUnboundedInterval(A lowerBound) { return(Interval(lowerBound: IntervalBound.Closed(lowerBound))); }
/// <summary> /// Creates an unbounded interval with open lower bound. /// </summary> public Interval <A> OpenUnboundedInterval(A lowerBound) { return(Interval(lowerBound: IntervalBound.Open(lowerBound))); }
/// <summary> /// Creates a closed interval with the specified bounds. /// </summary> public Interval <A> ClosedInterval(A lowerBound, A upperBound) { return(Interval(IntervalBound.Closed(lowerBound), IntervalBound.Closed(upperBound))); }
/// <summary> /// Creates an open interval with the specified bounds. /// </summary> public Interval <A> OpenInterval(A lowerBound, A upperBound) { return(Interval(IntervalBound.Open(lowerBound), IntervalBound.Open(upperBound))); }
/// <summary> /// Creates a new degenerate interval that consists of just one value. /// </summary> public Interval <A> SingleValueInterval(A value) { var bound = IntervalBound.Closed(value).ToOption(); return(new Interval <A>(bound, bound, isEmpty: false)); }