Class SwiftShortArray2D
- Namespace
- SwiftCollections.Dimensions
- Assembly
- SwiftCollections.dll
Represents a 2D array specifically designed to handle short integer values.
[JsonConverter(typeof(StateJsonConverterFactory))]
[MemoryPackable(GenerateType.Object)]
public class SwiftShortArray2D : SwiftArray2D<short>, IEnumerable<short>, IEnumerable, IMemoryPackable<SwiftArray2D<short>>, IStateBacked<Array2DState<short>>, IMemoryPackable<SwiftShortArray2D>, IMemoryPackFormatterRegister
- Inheritance
-
SwiftShortArray2D
- Implements
-
IMemoryPackable<SwiftShortArray2D>IMemoryPackFormatterRegister
- Inherited Members
- Extension Methods
Remarks
MemoryPack GenerateType: Object
SwiftCollections.Array2DState<short> State
Constructors
SwiftShortArray2D()
Initializes a new instance of the SwiftShortArray2D class.
public SwiftShortArray2D()
SwiftShortArray2D(Array2DState<short>)
Initializes a new instance of the SwiftShortArray2D class using the specified array state.
[MemoryPackConstructor]
public SwiftShortArray2D(Array2DState<short> state)
Parameters
stateArray2DState<short>The state to restore. Dimensions must be non-negative and their exact product must equal the non-null data array's length. Data is copied into independently owned storage.
Remarks
A zero dimension requires empty data. Unlike dimensional construction, restoration rejects negative dimensions instead of clamping them. Validation and copying complete before the restored state is installed.
Exceptions
- ArgumentNullException
The state data array is null.
- ArgumentOutOfRangeException
A state dimension is negative.
- OverflowException
The exact dimension product exceeds Int32.MaxValue.
- ArgumentException
The data length differs from the dimension product.
SwiftShortArray2D(short[,])
Initializes a new instance of the SwiftShortArray2D class using the specified two-dimensional array of short values.
public SwiftShortArray2D(short[,] source)
Parameters
sourceshort[,]The source rectangular array. Elements are shallow-copied; the source storage is not retained.
Exceptions
- NullReferenceException
source is null; this constructor does not use the AddRange null guard.
SwiftShortArray2D(int, int)
Initializes a new instance of the SwiftShortArray2D class with the specified dimensions.
public SwiftShortArray2D(int width, int height)
Parameters
widthintThe requested width in cells; negative values are clamped to zero.
heightintThe requested height in cells; negative values are clamped to zero.
Remarks
Negative dimensions are clamped before checking the exact dimension product. A zero dimension creates empty storage.
Exceptions
- OverflowException
The exact product of the clamped dimensions exceeds Int32.MaxValue.
SwiftShortArray2D(int, int, short)
Initializes a new instance of the SwiftShortArray2D class with the specified dimensions and default value.
public SwiftShortArray2D(int width, int height, short defaultValue)
Parameters
widthintThe requested width in cells; negative values are clamped to zero.
heightintThe requested height in cells; negative values are clamped to zero.
defaultValueshortThe value assigned to every selected cell; reference-type values are shared, not cloned.
Remarks
Negative dimensions are clamped before checking the exact dimension product. A zero dimension creates empty storage.
Exceptions
- OverflowException
The exact product of the clamped dimensions exceeds Int32.MaxValue.
Methods
Normalize(short, short)
Rescales the stored values in place using deterministic integer interpolation.
public void Normalize(short min, short max)
Parameters
minshortThe value assigned to the smallest input, or to every cell when the input is constant.
maxshortThe value assigned to the largest non-constant input. May be less than min for a descending mapping, or equal to min for a constant output.
Remarks
Maps the observed input range linearly onto the requested endpoints, truncating the final exact result toward zero. All Int16 inputs and endpoints are supported without overflow or floating-point arithmetic. Empty storage is unchanged. Constant input is filled with min. Dimensions and backing storage are preserved.
Scale(short)
Scales all elements in the array by the specified factor.
public void Scale(short factor)
Parameters
factorshortThe signed multiplier applied in place; results narrow to Int16 with unchecked wraparound.