TOC Toolkit API - v0.1.0
    Preparing search index...

    Class Interner<T>

    Gives every distinct value a dense id and returns the value of an id. The ids count from 0 in the order in which the values first appear. Two values are the same when the key function gives them the same key.

    Every operation takes constant expected time and one call of the key function. An interner with a budget charges one Resource.Cells for each new value.

    Type Parameters

    • T extends NonNullable<unknown>
    Index
    • Type Parameters

      • T extends {}

      Parameters

      • keyOf: (value: T) => string | number
      • Optionalbudget: Budget

      Returns Interner<T>

    • get size(): number

      The number of distinct values.

      Returns number

    • Returns the id of value, and gives the value the next id when it is new.

      Parameters

      • value: T

      Returns number

    • Returns the id of value, or undefined when the interner does not hold the value.

      Parameters

      • value: T

      Returns Maybe<number>

    • Returns the value that first received id.

      Parameters

      • id: number

      Returns T