Struct Range<T>
Represent a range of values.
Assembly: CarinaStudio.AppBase.Core.dll
Syntax
public readonly struct Range<T> : IEquatable<Range<T>> where T : struct, IComparable<T>
Type Parameters
Constructors
|
Improve this Doc
View Source
Range(Nullable<T>, Nullable<T>)
Initialize fields of structure,
Declaration
public Range(T? start, T? end)
Parameters
Type |
Name |
Description |
System.Nullable<T> |
start |
Start of range.
|
System.Nullable<T> |
end |
End of range.
|
Fields
|
Improve this Doc
View Source
Empty
Declaration
public static readonly Range<T> Empty
Field Value
Type |
Description |
Range<T> |
|
|
Improve this Doc
View Source
Universal
Declaration
public static readonly Range<T> Universal
Field Value
Type |
Description |
Range<T> |
|
Properties
|
Improve this Doc
View Source
End
Get the exclusive end of range. Returns Null if it is an open range without end.
Declaration
public readonly T? End { get; }
Property Value
Type |
Description |
System.Nullable<T> |
|
|
Improve this Doc
View Source
IsClosed
Check whether it is an closed range or not.
Declaration
public readonly bool IsClosed { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsEmpty
Check whether it is an empty range or not.
Declaration
public readonly bool IsEmpty { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsOpen
Check whether it is an open range without either start or end or both.
Declaration
public readonly bool IsOpen { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
IsUniversal
Check whether it is a universal range which covers all values or not.
Declaration
public readonly bool IsUniversal { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Start
Get the inclusive start of range. Returns Null if it is an open range without start.
Declaration
public readonly T? Start { get; }
Property Value
Type |
Description |
System.Nullable<T> |
|
Methods
|
Improve this Doc
View Source
Contains(T)
Check whether given value is contained in this range or not.
Declaration
public readonly bool Contains(T value)
Parameters
Type |
Name |
Description |
T |
value |
Value.
|
Returns
Type |
Description |
System.Boolean |
True if value is contained in this range.
|
|
Improve this Doc
View Source
Contains(Range<T>)
Check whether given range is contained in this range or not.
Declaration
public readonly bool Contains(Range<T> range)
Parameters
Type |
Name |
Description |
Range<T> |
range |
Range.
|
Returns
Type |
Description |
System.Boolean |
True if value is contained in this range.
|
|
Improve this Doc
View Source
ContainsOrEquals(Range<T>)
Check whether given range is contained in or equivalent to this range or not.
Declaration
public readonly bool ContainsOrEquals(Range<T> range)
Parameters
Type |
Name |
Description |
Range<T> |
range |
Range.
|
Returns
Type |
Description |
System.Boolean |
True if value is contained in or equivalent to this range.
|
|
Improve this Doc
View Source
Equals(Range<T>)
Declaration
public readonly bool Equals(Range<T> range)
Parameters
Type |
Name |
Description |
Range<T> |
range |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Equals(Nullable<Object>)
Declaration
public override readonly bool Equals(object? obj)
Parameters
Type |
Name |
Description |
System.Nullable<System.Object> |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
GetHashCode()
Declaration
public override readonly int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
IntersectsWith(Range<T>)
Get the intersected range of this range and given range.
Declaration
public readonly Range<T> IntersectsWith(Range<T> range)
Parameters
Type |
Name |
Description |
Range<T> |
range |
Range.
|
Returns
Type |
Description |
Range<T> |
Intersected range.
|
|
Improve this Doc
View Source
IsIntersectedWith(Range<T>)
Check whether the range is intersected with given range or not.
Declaration
public readonly bool IsIntersectedWith(Range<T> range)
Parameters
Type |
Name |
Description |
Range<T> |
range |
Range.
|
Returns
Type |
Description |
System.Boolean |
True if the range is intersected with given range.
|
|
Improve this Doc
View Source
ToString()
Declaration
public override readonly string ToString()
Returns
Type |
Description |
System.String |
|
Operators
|
Improve this Doc
View Source
Equality(Range<T>, Range<T>)
Declaration
public static bool operator ==(Range<T> x, Range<T> y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Implicit(Range<T> to (Nullable<T>, Nullable<T>))
Implicit type conversion operator.
Declaration
public static implicit operator (T? , T? )(Range<T> range)
Parameters
Type |
Name |
Description |
Range<T> |
range |
|
Returns
Type |
Description |
System.ValueTuple<System.Nullable<T>, System.Nullable<T>> |
|
|
Improve this Doc
View Source
Implicit((T, T) to Range<T>)
Implicit type conversion operator.
Declaration
public static implicit operator Range<T>((T, T) range)
Parameters
Type |
Name |
Description |
System.ValueTuple<T, T> |
range |
|
Returns
Type |
Description |
Range<T> |
|
|
Improve this Doc
View Source
Implicit((Nullable<T>, Nullable<T>) to Range<T>)
Implicit type conversion operator.
Declaration
public static implicit operator Range<T>((T? , T? ) range)
Parameters
Type |
Name |
Description |
System.ValueTuple<System.Nullable<T>, System.Nullable<T>> |
range |
|
Returns
Type |
Description |
Range<T> |
|
|
Improve this Doc
View Source
Inequality(Range<T>, Range<T>)
Declaration
public static bool operator !=(Range<T> x, Range<T> y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implements
IEquatable<>
Extension Methods