Class PointerSetBlock<T, K, R>

Class representing an expanded block in a PointerSet data store. These are created on demand, they are NOT intended to be instantiated directly.

Exported for the benefit of type checking and extension use cases.

Type Parameters

Hierarchy

  • PointerSetBase<T, K, R>
    • PointerSetBlock

Implements

Implemented by

Constructors

  • Class representing an expanded block in a PointerSet data store. These are created on demand, they are NOT intended to be instantiated directly.

    Exported for the benefit of type checking and extension use cases.

    Type Parameters

    Parameters

    • blocks: PointerSetBlock<T, K, R>[]
    • blocksAvail: Set<PointerSetBlock<T, K, R>>
    • names: { [ k in string]: FieldId }
    • wordSize: WordSize
    • shift: Shift
    • mask: Mask
    • blockIdMask: BlockIdMask
    • blockSize: BlockSize

    Returns PointerSetBlock<T, K, R>

Properties

blockId: BlockId
blockIdMask: BlockIdMask
blockSize: BlockSize
blocks: PointerSetBlock<T, K, R>[]
blocksAvail: Set<PointerSetBlock<T, K, R>>
fields: Uint32Array[]
firstNextFree: FirstNextFree = ...
freeList: Stack
mask: Mask
names: { [ k in string]: FieldId }
nextFree: Index = ...
rawFields: Uint32Array[]
shift: Shift
shiftDownFix: ShiftDownFix
shiftUpFix: ShiftUpFix = ...

shifting UP to get a block id from a pointer always overflows in the same way, because we are converting from an int32 into a uint32

values: (undefined | T)[] = []
wordSize: WordSize

Methods

  • Allocate a new pointer in the set, associated with the supplied value parameter.

    Any pointers passed in the refs argument are assigned as pointers stored in the associated fields slab.

    Any raw numeric values in the raws argument are stored in the associated rawFields slab.

    Parameters

    • value: T
    • Optional refs: RefSet<K>
    • Optional raw: RawSet<R>

    Returns Pointer

  • number of available spaces in a given block

    Parameters

    • blockId: number

    Returns number

  • Number of blocks in the PointerSet

    Returns number

  • Drop block from the set, or wipeBlock() if the root block. Only allowed on the last block in the stack.

    Returns void

  • Pop any empty blocks off the end of the stack.

    Returns void

  • number of entries in a given block

    Parameters

    • blockId: number

    Returns number

  • Mark a pointer location as free for re-use, delete its value from the values array, and set any refs and raw values to 0.

    See also free() for a faster version of this that does not set the data in the fields/rawFields slabs to 0.

    Parameters

    Returns void

  • Mark a Pointer location as free for re-use, and delete its value from the values array.

    Note that this does not delete raw values and references from the relevant data slabs, so it is still possible to dereference previously freed pointers, and get their former values.

    See erase() if you need this.

    Parameters

    Returns void

  • For internal use: get a BlockId from a Pointer

    Parameters

    Returns BlockId

  • For internal use: get an Index from a Pointer

    Parameters

    Returns Index

  • For internal use: get a Pointer from a BlockId and Index

    Parameters

    • blockId: BlockId
    • index: Index

    Returns Pointer

  • Parameters

    • pointer: Pointer
    • field: FieldName<R>

    Returns Uint32Array

  • Get the raw data from the supplied pointer, in the specified rawField

    Parameters

    • pointer: Pointer
    • field: FieldName<R>

    Returns number

  • Set the raw data from the supplied pointer, in the specified rawField

    Parameters

    • pointer: Pointer
    • field: FieldName<R>
    • val: number

    Returns number

  • Get the raw data from the supplied pointer, in the supplied rawField, as a 2-word Uint16Array view. Editing the view will update the value.

    Parameters

    • pointer: Pointer
    • field: FieldName<R>

    Returns Uint16ArrayLength2

  • Set the raw data for the supplied pointer, in the supplied rawField, to the values set in a 2-word Uint16Array. Returns a 2-word Uint16Array view. Editing the view will update the value.

    Parameters

    • pointer: Pointer
    • field: FieldName<R>
    • val: Uint16Array

    Returns Uint16ArrayLength2

  • Get the raw data from the supplied pointer, in the supplied rawField, as a 1-word Uint32Array view. Editing the view will update the value.

    Parameters

    • pointer: Pointer
    • field: FieldName<R>

    Returns Uint32ArrayLength1

  • Set the raw data for the supplied pointer, in the supplied rawField, to the values set in a 1-word Uint32Array. Returns a 1-word Uint32Array view. Editing the view will update the value.

    Parameters

    • pointer: Pointer
    • field: FieldName<R>
    • val: Uint32Array

    Returns Uint32ArrayLength1

  • Get the raw data from the supplied pointer, in the supplied rawField, as a 4-byte Uint8Array view. Editing the view will update the value.

    Parameters

    • pointer: Pointer
    • field: FieldName<R>

    Returns Uint8ArrayLength4

  • Set the raw data for the supplied pointer, in the supplied rawField, to the values set in a 4-byte Uint8Array. Returns a 4-byte Uint8Array view. Editing the view will update the value.

    Parameters

    • pointer: Pointer
    • field: FieldName<R>
    • val: Uint8Array

    Returns Uint8ArrayLength4

  • get all raw values, or set zero or more in an object

    Parameters

    • pointer: Pointer
    • Optional raws: RawSet<R>

    Returns RawSet<R>

  • Get the reference from the supplied pointer, in the specified field

    Parameters

    • pointer: Pointer
    • field: FieldName<K>

    Returns Pointer

  • Set the reference from the supplied pointer, in the specified field

    Parameters

    Returns Pointer

  • get all reference values, or set zero or more in an object

    Parameters

    • pointer: Pointer
    • Optional refs: RefSet<K>

    Returns RefSet<K>

  • Total number of entries in the entire PointerSet Note that it is always at least 1, because the root block's zero-entry is reserved for the nullPointer.

    Returns number

  • Total number of available spaces in the entire PointerSet.

    Returns number

  • Get the data for a given pointer from the values array

    Parameters

    Returns undefined | T

  • Set the data for a given pointer in the values array

    Parameters

    Returns T

  • Erase all data in the slab.

    Returns void

Generated using TypeDoc