Struct Interval<T>.Closed
Represents a closed interval [Start, End] over a comparable type, modeled as a set with membership and containment operations.
public struct Interval<T>.Closed : INonEnumerableSet<T>, IEquatable<Interval<T>.Closed>
- Implements
- Inherited Members
Remarks
The closed convention [Start, End] means both bounds are inclusive.
The interval is empty when Start > End.
Constructors
Closed(T, T)
Creates a new closed interval [start, end].
public Closed(T start, T end)
Parameters
startTendT
Fields
End
The inclusive upper bound of the interval.
public T End
Field Value
- T
Start
The inclusive lower bound of the interval.
public T Start
Field Value
- T
Properties
IsEmpty
Whether this interval represents the empty set (Start > End).
public bool IsEmpty { get; }
Property Value
Methods
Contains(Closed)
Subset test: other ⊆ this.
public bool Contains(Interval<T>.Closed other)
Parameters
Returns
Contains(T)
Membership test: value ∈ [Start, End].
public bool Contains(T value)
Parameters
valueT
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(Closed)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Interval<T>.Closed other)
Parameters
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Intersect(Closed)
Set intersection: this ∩ other.
Returns ∅ if the intervals do not overlap.
public Interval<T>.Closed Intersect(Interval<T>.Closed other)
Parameters
Returns
Overlaps(Closed)
Whether two intervals share any elements (this ∩ other ≠ ∅).
public bool Overlaps(Interval<T>.Closed other)
Parameters
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(Closed, Closed)
public static bool operator ==(Interval<T>.Closed left, Interval<T>.Closed right)
Parameters
Returns
implicit operator Closed((T Start, T End))
Implicit conversion from a 2-tuple to a closed interval.
public static implicit operator Interval<T>.Closed((T Start, T End) tuple)
Parameters
Returns
operator !=(Closed, Closed)
public static bool operator !=(Interval<T>.Closed left, Interval<T>.Closed right)