Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace SparseMap

A high-performance map that references values using unsigned integers.

Index

Type aliases

Iteratee

Iteratee<$Value, $Key>: (value: $Value, key: $Key) => void

Type parameters

  • $Value

  • $Key: number

Type declaration

    • (value: $Value, key: $Key): void
    • A callback function passed to SparseMap.forEach

      Parameters

      • value: $Value
      • key: $Key

      Returns void

Struct

Struct<$Value, $Key>: { size: number }

A map that references values using unsigned integers. Uses a packed array in conjunction with a key-value index for fast lookup, add/remove operations, and iteration. SparseMap is used frequently in Harmony since entities (including schema and game objects) are represented as unsigned integers.

SparseMap is faster than ES Maps in all cases. It is slower than sparse arrays for read/write operations, but faster to iterate.

Type parameters

  • $Value = unknown

  • $Key: number = number

Type declaration

  • size: number
    readonly

Functions

make

  • make<$Value, $Key>(init?: (undefined | $Value)[]): SparseMap.Struct<$Value, $Key>

get

  • get<$Value, $Key>(map: SparseMap.Struct<$Value, $Key>, key: $Key): $Value | undefined
  • Retrieve the value for a given key from a SparseMap. Returns undefined if no record exists for the given key.

    Type parameters

    • $Value

    • $Key: number

    Parameters

    Returns $Value | undefined

set

  • set<$Value, $Key>(map: SparseMap.Struct<$Value, $Key>, key: $Key, value: $Value): void
  • Add or update the value of an entry with the given key within a SparseMap.

    Type parameters

    • $Value

    • $Key: number

    Parameters

    Returns void

remove

has

  • Check for the existence of a value by key within a SparseMap. Returns true if the SparseMap contains an entry for the provided key.

    Parameters

    Returns boolean

clear

forEach

Generated using TypeDoc