Struct Interval<T>.ClosedOpen
Represents a half-open interval [Start, End) over a comparable type, modeled as a set with membership and containment operations.
public struct Interval<T>.ClosedOpen : INonEnumerableSet<T>, IEquatable<Interval<T>.ClosedOpen>
- Implements
- Inherited Members
Remarks
The half-open convention [Start, End) means Start is inclusive and End is exclusive.
The interval is empty when Start >= End, making [n, n) a natural
representation for a cursor position with no selection.
Constructors
ClosedOpen(T, T)
Creates a new half-open interval [start, end).
public ClosedOpen(T start, T end)
Parameters
startTendT
Fields
End
The exclusive 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(ClosedOpen)
Subset test: other ⊆ this.
public bool Contains(Interval<T>.ClosedOpen other)
Parameters
otherInterval<T>.ClosedOpen
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(ClosedOpen)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Interval<T>.ClosedOpen other)
Parameters
otherInterval<T>.ClosedOpenAn object to compare with this object.
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(ClosedOpen)
Set intersection: this ∩ other.
Returns ∅ if the intervals do not overlap.
public Interval<T>.ClosedOpen Intersect(Interval<T>.ClosedOpen other)
Parameters
otherInterval<T>.ClosedOpen
Returns
Overlaps(ClosedOpen)
Whether two intervals share any elements (this ∩ other ≠ ∅).
public bool Overlaps(Interval<T>.ClosedOpen other)
Parameters
otherInterval<T>.ClosedOpen
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(ClosedOpen, ClosedOpen)
public static bool operator ==(Interval<T>.ClosedOpen left, Interval<T>.ClosedOpen right)
Parameters
leftInterval<T>.ClosedOpenrightInterval<T>.ClosedOpen
Returns
implicit operator ClosedOpen((T Start, T End))
Implicit conversion from a 2-tuple to a half-open interval.
public static implicit operator Interval<T>.ClosedOpen((T Start, T End) tuple)
Parameters
Returns
operator !=(ClosedOpen, ClosedOpen)
public static bool operator !=(Interval<T>.ClosedOpen left, Interval<T>.ClosedOpen right)
Parameters
leftInterval<T>.ClosedOpenrightInterval<T>.ClosedOpen