Show / Hide Table of Contents

Class Dimension

Represents a fixed-length dimension to shape a space (Space object).

Inheritance
System.Object
Dimension
Implements
System.Collections.Generic.IEnumerable<System.Int32>
System.Collections.IEnumerable
System.ICloneable
Namespace: MultidimLib
Syntax
public sealed class Dimension : IEnumerable<int>, IEnumerable, ICloneable

Constructors

Dimension(Int32)

Initializes a new dimension (Dimension) with lower coordinate equals to 0 and the specified upper coordinate.

Declaration
public Dimension(int upperCoordinate)
Parameters
Type Name Description
System.Int32 upperCoordinate

The inclusive upper coordinate of the dimension.

Dimension(Int32, Int32)

Initializes a new dimension (Dimension) with the specified lower and upper coordinates.

Declaration
public Dimension(int lowerCoordinate, int upperCoordinate)
Parameters
Type Name Description
System.Int32 lowerCoordinate

The inclusive lower coordinate of the dimension.

System.Int32 upperCoordinate

The inclusive upper coordinate of the dimension.

Exceptions
Type Condition
DimensionException

Thrown when the lower coordinate is greater than the upper coordinate.

Properties

Default

A dimension whose lower and upper coordinates are equal to 0 and thus its length is equal to 1.

Declaration
public static Dimension Default { get; }
Property Value
Type Description
Dimension

The default dimension.

Length

Gets the length of the current dimension.

Declaration
public int Length { get; }
Property Value
Type Description
System.Int32

The length of the dimension, which is equal to the upper coordinate minus the lower coordinate plus 1.

LowerCoordinate

Gets the inclusive lower coordinate of the current dimension.

Declaration
public int LowerCoordinate { get; }
Property Value
Type Description
System.Int32

The inclusive lower coordinate of the dimension.

UpperCoordinate

Gets the inclusive upper coordinate of the current dimension.

Declaration
public int UpperCoordinate { get; }
Property Value
Type Description
System.Int32

The inclusive upper coordinate of the dimension.

Methods

Clone()

Makes a copy of the current dimension without associating it to any space.

Declaration
public Dimension Clone()

Equals(Dimension)

Determines whether a provided dimension is equal to the current dimension by checking their lower and upper coordinates (value equality).

Declaration
public bool Equals(Dimension dimension)
Parameters
Type Name Description
Dimension dimension

The dimension against which to compare equality.

Equals(Object)

Determines whether a provided object is the current dimension (reference equality).

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The object against which to compare equality.

Overrides
System.Object.Equals(System.Object)

FromLength(Int32)

Initializes a new dimension (Dimension object) with the provided length and lower coordinate equals to 0.

Declaration
public static Dimension FromLength(int length)
Parameters
Type Name Description
System.Int32 length

The length of the dimension.

Exceptions
Type Condition
DimensionException

Thrown when the provided length is lower than 1.

FromLengths(IEnumerable<Int32>)

Initializes and yields a number of dimensions (Dimension objects) with the provided lengths and lower coordinate equals to 0.

Declaration
public static IEnumerable<Dimension> FromLengths(IEnumerable<int> lengths)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Int32> lengths

The lengths of the dimensions.

Exceptions
Type Condition
DimensionException

Thrown when any of the provided lengths is lower than 1.

FromLowerCoordinateAndLength(Int32, Int32)

Initializes a new dimension (Dimension object) with the provided lower coordinate and length.

Declaration
public static Dimension FromLowerCoordinateAndLength(int lowerCoordinate, int length)
Parameters
Type Name Description
System.Int32 lowerCoordinate

The inclusive lower coordinate of the dimension.

System.Int32 length

The length of the dimension.

Exceptions
Type Condition
DimensionException

Thrown when the provided length is lower than 1.

HoldsCoordinate(Int32)

Determines whether a provided coordinate inclusively fits between the lower and upper coordinates of the current dimension. Returns true if so, false otherwise.

Declaration
public bool HoldsCoordinate(int coordinate)
Parameters
Type Name Description
System.Int32 coordinate

The coordinate to test.

ToString()

Returns a string representation of the current dimension formed as: "[LowerCoordinate, UpperCoordinate]|Length".

Declaration
public override string ToString()
Overrides
System.Object.ToString()

Explicit Interface Implementations

IEnumerable<Int32>.GetEnumerator()

Returns an enumerator that iterates over every possible coordinate that inclusively fits between the lower and upper coordinates of the current dimension.

Declaration
public IEnumerator<int> IEnumerable<int>.GetEnumerator()

Extension Methods

Initialization.C<T>(T)
Initialization.P(IEnumerable<Int32>)
Back to top MultidimLib from Ecuador.