Table of Contents

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

value Interval<T>

An Interval<T> reference.

Returns

IntervalCollection<T>

An IntervalCollection<T> that contains elements not in the specified interval.

Type Parameters

T

The 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

args Interval<T>[]

The Interval<T> arguments.

Returns

IntervalCollection<T>

An IntervalCollection<T> that contains elements not in the specified intervals.

Type Parameters

T

The value type of the intervals.

Exceptions

ArgumentNullException

args is null.

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

interval Interval<T>

An Interval<T> reference.

value T

The value to search for.

Returns

bool

true if the interval contains the value; otherwise, false.

Type Parameters

T

The 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

a Interval<T>

The first interval.

b Interval<T>

The second interval.

Returns

IntervalCollection<T>

An IntervalCollection<T> that contains elements in a but not in b.

Type Parameters

T

The 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

T

The 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

a Interval<T>

The first interval.

b Interval<T>

The second interval.

Returns

bool

true if the Interval<T> a intersects the interval b; otherwise, false.

Type Parameters

T

The 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

args Interval<T>[]

The Interval<T> arguments.

Returns

Interval<T>

An Interval<T> that contains elements belonging to all specified intervals.

Type Parameters

T

The value type of the intervals.

Exceptions

ArgumentNullException

args is null.

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

value Interval<T>

An Interval<T> reference.

Returns

bool

true if the value parameter is null or an emty interval; otherwise, false.

Type Parameters

T

The value type of the interval.

SingletonOf<T>(T)

Gets a singleton of the specified element.

public static Interval<T> SingletonOf<T>(T value)

Parameters

value T

The element value.

Returns

Interval<T>

An Interval<T> containing only the specified value.

Type Parameters

T

The value type of the intervals.

Exceptions

ArgumentNullException

value is 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

a Interval<T>

The first interval.

b Interval<T>

The second interval.

intersection Interval<T>

When this method returns, contains the Interval<T> that contains all elements of a that also belong to b; otherwise, an empty interval.

Returns

bool

true if the intersection is not empty; otherwise, false.

Type Parameters

T

The 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

args Interval<T>[]

The Interval<T> arguments.

Returns

IntervalCollection<T>

An IntervalCollection<T> that contains all distinct elements of the specified intervals.

Type Parameters

T

The value type of the intervals.

Exceptions

ArgumentNullException

args is null.

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

denominator UnionDenominator

The denominator considered while performing the union.

args Interval<T>[]

The Interval<T> arguments.

Returns

IntervalCollection<T>

An IntervalCollection<T> that contains all distinct elements of the specified intervals.

Type Parameters

T

The 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

args is null.

Universe<T>()

Gets the universe Interval<T>.

public static Interval<T> Universe<T>()

Returns

Interval<T>

Type Parameters

T

The 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:

  1. if T is 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.
  2. if T is exposing the NegativeInfinity and PositiveInfinity fields, they represent respectively the lowest and upmost values, as for float, double.
  3. if T is exposing the MinValue and MaxValue fields, they represent respectively the lowest and upmost values, as for byte, int, DateTime or char…
  4. 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