For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
Class StructArrayAbstract
Hierarchy (View Summary)
- StructArray
- StructArrayLayout6i1ul2ui20
- StructArrayLayout1ul2ui8
- StructArrayLayout3i6
- StructArrayLayout3ui6
- StructArrayLayout2ui4
- StructArrayLayout1ui2
- StructArrayLayout1f4
- StructArrayLayout1ui2f12
- StructArrayLayout8i15ui1ul2f2ui1f68
- StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52
- StructArrayLayout4i4ui4i1f28
- StructArrayLayout3f12
- StructArrayLayout1ul4
- StructArrayLayout2ub2f2i16
- StructArrayLayout2i4
- StructArrayLayout2i4ub8
- StructArrayLayout2f8
- StructArrayLayout2i4i12
Index
Constructors
Properties
Methods
Constructors
constructor
Returns StructArray
Properties
arrayBuffer
arrayBuffer: ArrayBuffer
bytesPerElement
bytesPerElement: number
capacity
capacity: number
isTransferred
isTransferred: boolean
length
length: number
members
uint8
uint8: Uint8Array
Methods
clear
Resets the length of the array to 0 without de-allocating capacity.
Returns void
Abstractemplace
Parameters
- i: number
- ...v: number[]
Returns number
AbstractemplaceBack
Parameters
- ...v: number[]
Returns number
freeBufferAfterUpload
Replace the buffer with an empty one so typed views release the original ArrayBuffer for GC.
Returns void
reserve
Indicate a planned increase in size, so that any necessary allocation may be done once, ahead of time.
Parameters
- n: number
The expected size of the array.
Returns void
- n: number
resize
Resize the array. If
nis greater than the current length then additional elements with undefined values are added. Ifnis less than the current length then the array will be reduced to the firstnelements.Parameters
- n: number
The new size of the array.
Returns void
- n: number
Staticdeserialize
- deserialize<T extends StructArray>(
this: { prototype: T } & new () => T,
input: SerializedStructArray,
): TType Parameters
- T extends StructArray
Parameters
- this: { prototype: T } & new () => T
- input: SerializedStructArray
Returns T
Staticserialize
Serialize a StructArray instance. Serializes both the raw data and the metadata needed to reconstruct the StructArray base class during deserialization.
Parameters
- array: StructArray
Optionaltransferables: Transferable[]
Returns SerializedStructArray
Internal
StructArrayprovides an abstraction overArrayBufferandTypedArraymaking it behave like an array of typed structs.Conceptually, a StructArray is comprised of elements, i.e., instances of its associated struct type. Each particular struct type, together with an alignment size, determines the memory layout of a StructArray whose elements are of that type. Thus, for each such layout that we need, we have a corresponding StructArrayLayout class, inheriting from StructArray and implementing
emplaceBack()and_refreshViews().In some cases, where we need to access particular elements of a StructArray, we implement a more specific subclass that inherits from one of the StructArrayLayouts and adds a
get(i): Taccessor that returns a structured object whose properties are proxies into the underlying memory space for the i-th element. This affords the convenience of working with (seemingly) plain Javascript objects without the overhead of serializing/deserializing them into ArrayBuffers for efficient web worker transfer.