@tspro/ts-utils-lib
    Preparing search index...

    Class SmallIntCache<VALUE>

    A cache-like structure optimized for small-range integer keys, including negatives.

    Internally implemented using two sparse arrays: one for non-negative keys, and one for negative keys (stored by index -key - 1).

    • Fast access for small integer keys.
    • Not suitable for large or sparse key ranges — memory usage may grow significantly.
    • Supports get, set, delete, has and clear
    const cache = new SmallIntCache<string>();
    cache.set(-2, 'A');
    cache.set(3, 'B');
    console.log(cache.get(-2)); // 'A'

    Type Parameters

    • VALUE
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Returns void

    • Parameters

      • key: number

      Returns void

    • Parameters

      • key: number

      Returns undefined | VALUE

    • Parameters

      • key: number

      Returns boolean

    • Parameters

      Returns void