Skip to main content

SalArray<T>

Namespace: PPJ.Runtime

Assembly: PPJ.Runtime.50 (5.0.0.0)

Provides a typed SAL array with dynamic first-dimension growth and optional explicit bounds.

public class SalArray<T> : SalArray, IEnumerable<T>, IList<T>, ICollection<T>

Reads and writes can grow the first dimension of a dynamic array. Index values follow the declared bounds; dimension arguments are one-based. The backing array may contain additional unused capacity.

Example:

using PPJ.Runtime;

SalArray<SalString> names = new SalArray<SalString>();
names.Add("Ada");
names.Add("Grace");
SalString first = names[0];

SalArray<SalNumber> grid = new SalArray<SalNumber>(2, 3);
grid[1, 2] = 42;
SalNumber columns = grid.GetLength(2); // Dimensions are one-based.

Parameters

NameDescription
TThe element type, which must have a public parameterless constructor.

Constructors

Instance member SalArray()

Initializes a SAL array with an empty dynamic first dimension.

Instance member SalArray(lengths)

Initializes a SAL array with the supplied dimension lengths.

NameTypeDescription
lengthsInt32[]The length of each dimension. A first length of -1 creates a dynamic first dimension; later lengths must be nonnegative.

Instance member SalArray(bounds)

Initializes a SAL array with the supplied dimension bounds.

NameTypeDescription
boundsString[]Each dimension as a length, a lower:upper range, or * for a dynamic first dimension. Null or no strings creates an empty dynamic array.

Properties

Instance member Item(index)

T: Gets or sets an element using SAL bounds and initialization rules.

For dynamic arrays, either access can extend the first dimension. Reading an uninitialized reference slot creates a default instance. Assignment converts compatible values to the element type; null is rejected for value types and SalString.

Instance member Item(indices)

T: Gets or sets an element using SAL bounds and initialization rules.

For dynamic arrays, either access can extend the first dimension. Reading an uninitialized reference slot creates a default instance. Assignment converts compatible values to the element type; null is rejected for value types and SalString.

Instance member Items

T[]: Gets the current typed backing vector.

Returns the live storage, including capacity beyond the logical length. Direct writes bypass SAL conversion and initialization rules. Use a one-dimensional array.

Methods

Instance member Add(item)

Appends an element to a one-dimensional array.

ParameterTypeDescription
itemTThe element to append.

Makes the array dynamic and writes at Count. Use zero-based arrays for conventional append behavior.

Instance member AddRange(collection)

Appends the supplied elements to a one-dimensional array.

ParameterTypeDescription
collectionIEnumerable<T>The sequence of elements to append.

Makes the array dynamic and repeatedly calls Add. Use zero-based arrays for conventional append behavior.

Instance member Contains(item)

Tests whether a one-dimensional array contains an element.

ParameterTypeDescription
itemTThe element to locate.

Returns: Boolean. True if IndexOf returns a nonnegative index; otherwise, false.

Instance member CopyTo(array)

Copies the logical elements to an existing typed array.

ParameterTypeDescription
arrayT[]The destination array with sufficient space.

Copies elements from the backing storage without performing lazy element initialization.

Instance member CopyTo(array, arrayIndex)

Copies the logical elements to an existing typed array.

ParameterTypeDescription
arrayT[]The destination array with sufficient space.
arrayIndexInt32The first destination index.

Copies elements from the backing storage without performing lazy element initialization.

Protected member CreateInstance()

Creates the default instance used to initialize an element.

Returns: Object. A new T instance.

Instance member GetArray()

Returns the typed backing array after ensuring the supplied indices are addressable.

Returns: T[]. The live backing array, including unused capacity.

The requested rank must match the array rank. Supplied values are indices, not minimum element counts. Access can grow the first dimension and initialize the addressed element.

Instance member GetArray(minLength)

Returns the typed backing array after ensuring the supplied indices are addressable.

ParameterTypeDescription
minLengthInt32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.

Returns: T[]. The live backing array, including unused capacity.

The requested rank must match the array rank. Supplied values are indices, not minimum element counts. Access can grow the first dimension and initialize the addressed element.

Instance member GetArray(minLength1, minLength2)

Returns the typed backing array after ensuring the supplied indices are addressable.

ParameterTypeDescription
minLength1Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.
minLength2Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.

Returns: T[,]. The live backing array, including unused capacity.

The requested rank must match the array rank. Supplied values are indices, not minimum element counts. Access can grow the first dimension and initialize the addressed element.

Instance member GetArray(minLength1, minLength2, minLength3)

Returns the typed backing array after ensuring the supplied indices are addressable.

ParameterTypeDescription
minLength1Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.
minLength2Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.
minLength3Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.

Returns: T[,,]. The live backing array, including unused capacity.

The requested rank must match the array rank. Supplied values are indices, not minimum element counts. Access can grow the first dimension and initialize the addressed element.

Instance member GetArray(minLength1, minLength2, minLength3, minLength4)

Returns the typed backing array after ensuring the supplied indices are addressable.

ParameterTypeDescription
minLength1Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.
minLength2Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.
minLength3Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.
minLength4Int32The index to ensure is addressable in this dimension, despite the length-oriented parameter name.

Returns: T[,,,]. The live backing array, including unused capacity.

The requested rank must match the array rank. Supplied values are indices, not minimum element counts. Access can grow the first dimension and initialize the addressed element.

Instance member IndexOf(item)

Finds the first matching element in a one-dimensional array.

ParameterTypeDescription
itemTThe element to locate.

Returns: Int32. The matching array index, or -1 when no match is found.

Uses the base Find implementation and its SAL conversion rules.

Instance member IndexOf(item, index)

Finds the first matching element in a one-dimensional array.

ParameterTypeDescription
itemTThe element to locate.
indexInt32The first index to search, or -1 to use the lower bound.

Returns: Int32. The matching array index, or -1 when no match is found.

Uses the base Find implementation and its SAL conversion rules.

Instance member Insert(index, item)

Inserts an element at a specified position in a one-dimensional array.

ParameterTypeDescription
indexInt32The insertion index, from the lower bound through one past the upper bound.
itemTThe element to insert.

Instance member InsertRange(index, collection)

Inserts a sequence of elements at consecutive positions.

ParameterTypeDescription
indexInt32The insertion index.
collectionIEnumerable<T>The non-null sequence to insert, in enumeration order.

Only one-dimensional arrays are supported.

Instance member Remove(item)

Removes the first matching element from a one-dimensional array.

ParameterTypeDescription
itemTThe element to remove.

Returns: Boolean. True when a matching element was removed; otherwise, false.

Instance member RemoveAt(index)

Removes an element and shifts later elements toward the start.

ParameterTypeDescription
indexInt32The index of the element to remove.

Only one-dimensional arrays are supported. The logical length decreases by one.

Instance member Sort(comparison)

Sorts a one-dimensional array using a comparison delegate.

ParameterTypeDescription
comparisonComparison<T>The delegate used to compare two elements. Must not be null.

Sorts from index zero for the logical length; arrays with a nonzero lower bound should use the indexed base overload.

Implements

NameDescription
ISalTypeExposes a SAL value in the form used for database parameter binding.