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.
- C#
- VB.NET
public class SalArray<T> : SalArray, IEnumerable<T>, IList<T>, ICollection<T>
Public Class SalArray(Of T)
Inherits SalArray
Implements IEnumerable(Of T), IList(Of T), ICollection(Of 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
| Name | Description |
|---|---|
| T | The element type, which must have a public parameterless constructor. |
Constructors
SalArray()
Initializes a SAL array with an empty dynamic first dimension.
SalArray(lengths)
Initializes a SAL array with the supplied dimension lengths.
| Name | Type | Description |
|---|---|---|
| lengths | Int32[] | The length of each dimension. A first length of -1 creates a dynamic first dimension; later lengths must be nonnegative. |
SalArray(bounds)
Initializes a SAL array with the supplied dimension bounds.
| Name | Type | Description |
|---|---|---|
| bounds | String[] | 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
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.
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.
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
Add(item)
Appends an element to a one-dimensional array.
| Parameter | Type | Description |
|---|---|---|
| item | T | The element to append. |
Makes the array dynamic and writes at Count. Use zero-based arrays for conventional append behavior.
AddRange(collection)
Appends the supplied elements to a one-dimensional array.
| Parameter | Type | Description |
|---|---|---|
| collection | IEnumerable<T> | The sequence of elements to append. |
Makes the array dynamic and repeatedly calls Add. Use zero-based arrays for conventional append behavior.
Contains(item)
Tests whether a one-dimensional array contains an element.
| Parameter | Type | Description |
|---|---|---|
| item | T | The element to locate. |
Returns: Boolean. True if IndexOf returns a nonnegative index; otherwise, false.
CopyTo(array)
Copies the logical elements to an existing typed array.
| Parameter | Type | Description |
|---|---|---|
| array | T[] | The destination array with sufficient space. |
Copies elements from the backing storage without performing lazy element initialization.
CopyTo(array, arrayIndex)
Copies the logical elements to an existing typed array.
| Parameter | Type | Description |
|---|---|---|
| array | T[] | The destination array with sufficient space. |
| arrayIndex | Int32 | The first destination index. |
Copies elements from the backing storage without performing lazy element initialization.
CreateInstance()
Creates the default instance used to initialize an element.
Returns: Object. A new T instance.
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.
GetArray(minLength)
Returns the typed backing array after ensuring the supplied indices are addressable.
| Parameter | Type | Description |
|---|---|---|
| minLength | Int32 | The 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.
GetArray(minLength1, minLength2)
Returns the typed backing array after ensuring the supplied indices are addressable.
| Parameter | Type | Description |
|---|---|---|
| minLength1 | Int32 | The index to ensure is addressable in this dimension, despite the length-oriented parameter name. |
| minLength2 | Int32 | The 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.
GetArray(minLength1, minLength2, minLength3)
Returns the typed backing array after ensuring the supplied indices are addressable.
| Parameter | Type | Description |
|---|---|---|
| minLength1 | Int32 | The index to ensure is addressable in this dimension, despite the length-oriented parameter name. |
| minLength2 | Int32 | The index to ensure is addressable in this dimension, despite the length-oriented parameter name. |
| minLength3 | Int32 | The 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.
GetArray(minLength1, minLength2, minLength3, minLength4)
Returns the typed backing array after ensuring the supplied indices are addressable.
| Parameter | Type | Description |
|---|---|---|
| minLength1 | Int32 | The index to ensure is addressable in this dimension, despite the length-oriented parameter name. |
| minLength2 | Int32 | The index to ensure is addressable in this dimension, despite the length-oriented parameter name. |
| minLength3 | Int32 | The index to ensure is addressable in this dimension, despite the length-oriented parameter name. |
| minLength4 | Int32 | The 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.
IndexOf(item)
Finds the first matching element in a one-dimensional array.
| Parameter | Type | Description |
|---|---|---|
| item | T | The 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.
IndexOf(item, index)
Finds the first matching element in a one-dimensional array.
| Parameter | Type | Description |
|---|---|---|
| item | T | The element to locate. |
| index | Int32 | The 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.
Insert(index, item)
Inserts an element at a specified position in a one-dimensional array.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The insertion index, from the lower bound through one past the upper bound. |
| item | T | The element to insert. |
InsertRange(index, collection)
Inserts a sequence of elements at consecutive positions.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The insertion index. |
| collection | IEnumerable<T> | The non-null sequence to insert, in enumeration order. |
Only one-dimensional arrays are supported.
Remove(item)
Removes the first matching element from a one-dimensional array.
| Parameter | Type | Description |
|---|---|---|
| item | T | The element to remove. |
Returns: Boolean. True when a matching element was removed; otherwise, false.
RemoveAt(index)
Removes an element and shifts later elements toward the start.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The index of the element to remove. |
Only one-dimensional arrays are supported. The logical length decreases by one.
Sort(comparison)
Sorts a one-dimensional array using a comparison delegate.
| Parameter | Type | Description |
|---|---|---|
| comparison | Comparison<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
| Name | Description |
|---|---|
| ISalType | Exposes a SAL value in the form used for database parameter binding. |