gis-tools-ts - v0.6.0
    Preparing search index...

    Class MultiMap<V>

    MultiMap Store

    A local multimap store

    import { MultiMap } from 'gis-tools-ts';

    interface Data { name: string };

    const mm = new MultiMap<Data>();
    // set a key
    mm.set(1n, { name: 'test' });
    mm.set(1n, { name: 'test2' });
    // get a key
    const { name } = mm.get(1n); // [{ name: 'test' }, { name: 'test2' }]
    // check if a key exists
    mm.has(1n); // true
    // get length of the store
    console.log(mm.length); // 2

    // iterate over the store
    for await (const entry of mm) console.log(entry);

    // close the store
    mm.close();

    Type Parameters

    • V = Properties | Value

    Implements

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Builds a new MultiMap

      Type Parameters

      • V = Value | Properties

      Returns MultiMap<V>

    Accessors

    • get length(): number

      Returns number

      • the length of the map

    Methods

    • iterate through the values

      Returns AsyncGenerator<MMEntry<V>>

      • an iterator
    • Closes the store

      Returns void

    • iterate through the values

      Returns AsyncGenerator<MMEntry<V>>

      • The values in the store
    • Gets the list of values associated with a key

      Parameters

      • key: number | bigint

        the key

      Returns undefined | V[]

      the list of values if the map contains values for the key

    • Check if the key exists

      Parameters

      • key: number | bigint

        the key

      Returns boolean

      true if the key exists

    • Adds a value to the list of values associated with a key

      Parameters

      • key: number | bigint

        the key

      • value: V

        the value to store

      Returns void