Struct Range<T>
- Namespace
- CarinaStudio
- Assembly
- CarinaStudio.AppBase.Core.dll
Represent a range of values.
public readonly struct Range<T> : IEquatable<Range<T>> where T : struct, IComparable<T>
Type Parameters
T
- Implements
-
IEquatable<Range<T>>
- Inherited Members
- Extension Methods
Constructors
Range(T?, T?)
Initialize fields of Range structure,
public Range(T? start, T? end)
Parameters
start
T?Start of range.
end
T?End of range.
Remarks
start
and end
may be swapped if start
is greater than end
.
Fields
Empty
Empty range.
public static readonly Range<T> Empty
Field Value
- Range<T>
Universal
Universal range.
public static readonly Range<T> Universal
Field Value
- Range<T>
Properties
End
Get the exclusive end of range. Returns Null if it is an open range without end.
public T? End { get; }
Property Value
- T?
IsClosed
Check whether it is an closed range or not.
public bool IsClosed { get; }
Property Value
IsEmpty
Check whether it is an empty range or not.
public bool IsEmpty { get; }
Property Value
IsOpen
Check whether it is an open range without either start or end or both.
public bool IsOpen { get; }
Property Value
IsUniversal
Check whether it is a universal range which covers all values or not.
public bool IsUniversal { get; }
Property Value
Start
Get the inclusive start of range. Returns Null if it is an open range without start.
public T? Start { get; }
Property Value
- T?
Methods
Contains(Range<T>)
Check whether given range is contained in this range or not.
public bool Contains(Range<T> range)
Parameters
range
Range<T>Range.
Returns
- bool
True if value is contained in this range.
Contains(T)
Check whether given value is contained in this range or not.
public bool Contains(T value)
Parameters
value
TValue.
Returns
- bool
True if value is contained in this range.
ContainsOrEquals(Range<T>)
Check whether given range is contained in or equivalent to this range or not.
public bool ContainsOrEquals(Range<T> range)
Parameters
range
Range<T>Range.
Returns
- bool
True if value is contained in or equivalent to this range.
Equals(Range<T>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Range<T> range)
Parameters
range
Range<T>
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
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.
IntersectsWith(Range<T>)
Get the intersected range of this range and given range.
public Range<T> IntersectsWith(Range<T> range)
Parameters
range
Range<T>Range.
Returns
- Range<T>
Intersected range.
IsIntersectedWith(Range<T>)
Check whether the range is intersected with given range or not.
public bool IsIntersectedWith(Range<T> range)
Parameters
range
Range<T>Range.
Returns
- bool
True if the range is intersected with given range.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(Range<T>, Range<T>)
Equality operator.
public static bool operator ==(Range<T> x, Range<T> y)
Parameters
Returns
implicit operator (T?, T?)(Range<T>)
Implicit type conversion operator.
public static implicit operator (T?, T?)(Range<T> range)
Parameters
range
Range<T>
Returns
- (T?, T?)
implicit operator Range<T>((T?, T?))
Implicit type conversion operator.
public static implicit operator Range<T>((T?, T?) range)
Parameters
range
(T?, T?)
Returns
- Range<T>
implicit operator Range<T>((T, T))
Implicit type conversion operator.
public static implicit operator Range<T>((T, T) range)
Parameters
range
(T, T)
Returns
- Range<T>
operator !=(Range<T>, Range<T>)
Inequality operator.
public static bool operator !=(Range<T> x, Range<T> y)