An indexed map cache. Used to temporarily store objects and functions. For example, a raycast callback function to be called, once we get the result from the physics backend. Indices can be freed and re-used.

Methods

Methods

  • Store an element in the cache. Will return one of the freed indices, or a new one.

    Parameters

    • element: any

      An object or a function to store in the cache

    Returns number

    • Index number under which the element is stored.
  • Frees an index to allow a re-use of it in the future.

    Parameters

    • index: number

      An index to free. Once freed, the index might be used again.

    Returns void

  • Retrieves a stored element under the given index.

    Parameters

    • index: number

      An index of the element to retrieve.

    Returns any

    • Element stored under given index.