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

StructArray provides an abstraction over ArrayBuffer and TypedArray making 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): T accessor 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.

Hierarchy (View Summary)

Index

Constructors

Properties

arrayBuffer: ArrayBuffer
bytesPerElement: number
capacity: number
isTransferred: boolean
length: number
uint8: Uint8Array

Methods

  • Resets the length of the array to 0 without de-allocating capacity.

    Returns void

  • Parameters

    • i: number
    • ...v: number[]

    Returns number

  • Parameters

    • ...v: number[]

    Returns number

  • Replace the buffer with an empty one so typed views release the original ArrayBuffer for GC.

    Returns void

  • 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

  • Resize the array. If n is greater than the current length then additional elements with undefined values are added. If n is less than the current length then the array will be reduced to the first n elements.

    Parameters

    • n: number

      The new size of the array.

    Returns void

Was this helpful?