Class Interval
- Namespace
- Arc4u
- Assembly
- Arc4u.dll
Gathers operations performed on Interval<T>. This class cannot be inherited.
public static class Interval
- Inheritance
-
Interval
- Inherited Members
Methods
ComplementOf<T>(Interval<T>)
Determines the complement of an Interval<T>.
public static IntervalCollection<T> ComplementOf<T>(Interval<T> value)
Parameters
valueInterval<T>An Interval<T> reference.
Returns
- IntervalCollection<T>
An IntervalCollection<T> that contains elements not in the specified interval.
Type Parameters
TThe value type of the interval.
- See Also
ComplementOf<T>(params Interval<T>[])
Determines the complement of several intervals.
public static IntervalCollection<T> ComplementOf<T>(params Interval<T>[] args)
Parameters
argsInterval<T>[]The Interval<T> arguments.
Returns
- IntervalCollection<T>
An IntervalCollection<T> that contains elements not in the specified intervals.
Type Parameters
TThe value type of the intervals.
Exceptions
- ArgumentNullException
argsisnull.
Contains<T>(Interval<T>, T)
Determines whether an Interval<T> contains a specified value.
public static bool Contains<T>(Interval<T> interval, T value)
Parameters
intervalInterval<T>An Interval<T> reference.
valueTThe value to search for.
Returns
- bool
trueif theintervalcontains thevalue; otherwise,false.
Type Parameters
TThe value type of the interval.
DifferenceOf<T>(Interval<T>, Interval<T>)
Determines the difference of two intervals.
public static IntervalCollection<T> DifferenceOf<T>(Interval<T> a, Interval<T> b)
Parameters
Returns
- IntervalCollection<T>
An IntervalCollection<T> that contains elements in
abut not inb.
Type Parameters
TThe value type of the interval.
- See Also
Empty<T>()
Gets the default empty Interval<T>.
public static Interval<T> Empty<T>()
Returns
- Interval<T>
An Interval<T> containing no element.
Type Parameters
TThe value type of the intervals.
Remarks
An empty Interval<T> is composed of one element
(usually default(T) but not exclusively)
with Opened boundaries.
Except when T represents a reference type,
the default empty interval is composed of Closed boundaries.
It enables the distinction between the default Empty<T>() interval and
the Universe<T>() interval.
- See Also
Intersect<T>(Interval<T>, Interval<T>)
Determines whether two intervals intersect each other.
public static bool Intersect<T>(Interval<T> a, Interval<T> b)
Parameters
Returns
- bool
trueif the Interval<T>aintersects the intervalb; otherwise,false.
Type Parameters
TThe value type of the intervals.
IntersectionOf<T>(params Interval<T>[])
Determines the intersection of several intervals.
public static Interval<T> IntersectionOf<T>(params Interval<T>[] args)
Parameters
argsInterval<T>[]The Interval<T> arguments.
Returns
- Interval<T>
An Interval<T> that contains elements belonging to all specified intervals.
Type Parameters
TThe value type of the intervals.
Exceptions
- ArgumentNullException
argsisnull.
IsNullOrEmpty<T>(Interval<T>)
Indicates whether the specified Interval<T> object is null or an Empty<T>() interval.
public static bool IsNullOrEmpty<T>(Interval<T> value)
Parameters
valueInterval<T>An Interval<T> reference.
Returns
- bool
trueif thevalueparameter isnullor an emty interval; otherwise,false.
Type Parameters
TThe value type of the interval.
SingletonOf<T>(T)
Gets a singleton of the specified element.
public static Interval<T> SingletonOf<T>(T value)
Parameters
valueTThe element value.
Returns
- Interval<T>
An Interval<T> containing only the specified
value.
Type Parameters
TThe value type of the intervals.
Exceptions
- ArgumentNullException
valueis null.
- See Also
TryIntersectionOf<T>(Interval<T>, Interval<T>, out Interval<T>)
Determines the intersection of two intervals.
public static bool TryIntersectionOf<T>(Interval<T> a, Interval<T> b, out Interval<T> intersection)
Parameters
aInterval<T>The first interval.
bInterval<T>The second interval.
intersectionInterval<T>When this method returns, contains the Interval<T> that contains all elements of
athat also belong tob; otherwise, an empty interval.
Returns
- bool
true if the intersection is not empty; otherwise, false.
Type Parameters
TThe value type of the intervals.
UnionOf<T>(params Interval<T>[])
Determines the union of several intervals.
public static IntervalCollection<T> UnionOf<T>(params Interval<T>[] args)
Parameters
argsInterval<T>[]The Interval<T> arguments.
Returns
- IntervalCollection<T>
An IntervalCollection<T> that contains all distinct elements of the specified intervals.
Type Parameters
TThe value type of the intervals.
Exceptions
- ArgumentNullException
argsisnull.
UnionOf<T>(UnionDenominator, params Interval<T>[])
Determines the union of several intervals according to the specified denominator.
public static IntervalCollection<T> UnionOf<T>(UnionDenominator denominator, params Interval<T>[] args)
Parameters
denominatorUnionDenominatorThe denominator considered while performing the union.
argsInterval<T>[]The Interval<T> arguments.
Returns
- IntervalCollection<T>
An IntervalCollection<T> that contains all distinct elements of the specified intervals.
Type Parameters
TThe value type of the intervals.
Remarks
While performing an UnionOf intervals, depending of the specified UnionDenominator, the result will be different. If you consider the following intervals:
| a | ]∞ ; 3[ |
| b | ]0 ; 5[ |
| c | [1 ; 2] |
The union with the Highest denominator will return an IntervalCollection<T> of 1 element as shown below:
| i | ]∞ ; 5[ |
The union with the Lowest denominator will return an IntervalCollection<T> of 5 element as shown below:
| i | ]∞ ; 0] |
| j | ]0 ; 1[ |
| k | [1 ; 2] |
| l | ]2 ; 3[ |
| m | [3 ; 5[ |
Exceptions
- ArgumentNullException
argsisnull.
Universe<T>()
Gets the universe Interval<T>.
public static Interval<T> Universe<T>()
Returns
- Interval<T>
Type Parameters
TThe value type of the intervals.
Remarks
An universe Interval<T> is composed of the lowest and upmost values of T
with Opened boundaries when T represents a reference type
with Closed boundaries when T represents a value type.
The lowest and upmost values are determined in the following order:
- if
Tis an Enum, the lowest and upmost values are represented respectively by the lowest and upmost underlying values of the Enum. In case of Enum decorated with the FlagsAttribute, the upmost value is then represented by the combination of all underlying values of the Enum. - if
Tis exposing the NegativeInfinity and PositiveInfinity fields, they represent respectively the lowest and upmost values, as for float, double. - if
Tis exposing the MinValue and MaxValue fields, they represent respectively the lowest and upmost values, as for byte, int, DateTime or char… - otherwise,
default(T)represents the lowest and upmost values.
As a consequence default(T) could be used to represent the universe Interval<T> and the default Empty<T>() interval.
In this case only and by convention, the default empty Interval<T> is composed of Closed boudaries.
As another consequence, default(T) could be used to represent the universe Interval<T> and the SingletonOf<T>(T) the default value.
In such case the Interval<T> represents then universe and a singleton.
- See Also