@jiminp/tooltool
    Preparing search index...

    Function multimapAdd

    • Adds a value to the array for a key in a Map-backed multimap.

      Creates the array if the key doesn't exist.

      Type Parameters

      • K

        Key type.

      • V

        Value type.

      Parameters

      • m: Map<K, V[]>

        The multimap.

      • k: K

        The key.

      • v: V

        The value to add.

      Returns V[]

      The array for key k (same reference).

      const mm = new Map<string, number[]>();
      multimapAdd(mm, "a", 1);
      multimapAdd(mm, "a", 2);
      mm.get("a"); // [1, 2]
    • Adds a value to the array for a key in a Record-backed multimap.

      Creates the array if the key doesn't exist.

      Type Parameters

      • K extends PropertyKey

        Key type (must be PropertyKey).

      • V

        Value type.

      Parameters

      • m: Record<K, V[]>

        The multimap.

      • k: K

        The key.

      • v: V

        The value to add.

      Returns V[]

      The array for key k (same reference).