Create a new dynamic array from a TypedArray constructor and a starting capacity.
The TypedArray constructor. For example, if this dynamic array will be finalized to a Float32Array, then pass the Float32Array constructor to this parameter.
The starting capacity of the dynamic array, which is the length of the internal array.
Protected
_lengthThe actual typed array created by this dynamic array. If the dynamic array has been invalidated, then this will be null.
The TypedArray constructor. For example, if this dynamic array will be finalized to a Float32Array, then pass the Float32Array constructor to this parameter.
The current capacity of the dynamic array. Read-only; to expand the dynamic array, call expandCapacity.
The length of the dynamic array. Setting this will expand the dynamic array if necessary, but will not shrink.
Protected
assertCalls TypedArray.set on the internal array; copies a given array of values to a given offset.
The index to start copying to in the internal array.
The values to copy. All values in this array will be copied.
Calls TypedArray.fill on the internal array; fills the internal array with a value.
The value to fill the array with.
Optional
startIndex: numberThe start index of the range. 0 by default. Can be negative so that it's relative to the end of the array.
Optional
endIndex: numberThe end index of the range, exclusive. By default, goes to the end of the array. Can be negative so that it's relative to the end of the array.
Turns this dynamic array into a TypedArray ready to be used by external APIs. The dynamic array will be invalidated after this call.
Creates a new typed array as a view into the same buffer as array (array is invalidated, but not the underlying buffer).
A TypedArray instance with the right length.
Get the value at a given index.
The index to get.
Get the index of a value in the array, or -1 if not found.
Optional
fromIndex: numberAdd an element to the end of the array. Increases the length by 1, but does not expand the capacity to fit the new length, for optimisation purposes. Make sure to call expandCapacity before calling this method.
The value to push to the end of the array.
Private
resizeGet the value at a given index to a given value.
The index to set.
The value to set.
Calls TypedArray.slice on the internal array; copies a slice of the internal array, and returns that copy.
The start index of the range.
The end index of the range, exclusive.
Static
getGet the next capacity corresponding to an array length. For example, a wanted length of 0 will return the default starting capacity of a dynamic array. Capacity expands exponentially until a certain threshold, after which capacity expands linearly.
The array length used for the capacity calculations.
Generated using TypeDoc
A dynamic container that acts very similarly to C++ vectors. Wraps a typed array. Provides safe and unsafe accessors. Unsafe accessors are faster, but should only be used when your code is stable.