@unikue/ts-multi-map
    Preparing search index...

    Class MultiKeyMap<K, V>

    Map with entries that contains multiple keys and a single value

    David Hsing

    Type Parameters

    • K
    • V

    Implements

    • Omit<
          Map<K[], V>,

              | "delete"
              | "forEach"
              | "get"
              | "has"
              | "set"
              | "entries"
              | "keys"
              | "values"
              | "push",
      >
    Index

    Constructors

    Accessors

    • get "[toStringTag]"(): string

      Returns the string representation of the map identifier ('MultiKeyMap')

      Returns string

      the string representation of the map identifier

    • get size(): number

      Returns the size of map

      Returns number

      the size of map

    Methods

    • Response for returning the list of keys/value to iterate

      Returns IterableIterator<[K[], V]>

      for (const [keys, value] of map) {
      console.log(value);
      }
    • Clears the map

      Returns void

    • Deletes the entry with the given key

      Parameters

      • key: K[]

        the key to delete

      Returns boolean

      whether the entry has been deleted

      map.deleteByKey(['row1', 'col1']);
      
    • Deletes all the entries with the given keys

      Parameters

      • keys: K[][]

        the keys to delete

      Returns boolean

      whether any of the entries has been deleted

      map.deleteByKey([['row1', 'col1'], ['row2', 'col2']]);
      
    • Deletes the entry/entries with the given value

      Parameters

      • value: V

        the value to delete

      Returns boolean

      whether the entry/entries has been deleted

      map.deleteByValue('foo');
      
    • Deletes all the entries with any of the given values

      Parameters

      • values: V[]

        the values to delete

      Returns boolean

      whether any of the entries has been deleted

      map.deleteByValues(['foo', 'bar']);
      
    • Returns the keys/value entries of the map

      Returns [K[], V][]

      the keys/value entries of the map

    • Processes each entry in the map

      Parameters

      • callback: (value?: V, keys?: K[]) => void

        a callback function that processes each entry

      • OptionalthisArg: any

        any instance to retrieve 'this' reference in the callback function

      Returns void

      map.forEach((value, keys) => {
      console.log(value);
      });
    • Processes each entry in the map with breakable capability

      Parameters

      • callback: (value?: V, keys?: K[]) => boolean

        a callback function that processes each entry. Returning false indicates to break the map iteration

      • OptionalthisArg: any

        any instance to retrieve 'this' reference in the callback function

      Returns void

      map.forEachBreakable((value, keys) => {
      return true;
      });
    • Processes each entry in the map with index capability

      Parameters

      • callback: (value?: V, keys?: K[], index?: number) => void

        a callback function that processes each entry

      • OptionalthisArg: any

        any instance to retrieve 'this' reference in the callback function

      Returns void

      map.forEachIndexing((value, keys, index) => {
      console.log(index);
      });
    • Returns the value of the given keys

      Parameters

      • keys: K[]

        the keys to retrieve

      • Optionaldefaults: V

        the default value if not found

      Returns undefined | V

      the value of the given keys

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo']
      ]);
      map.get(['row1', 'col1']); // 'foo'
      map.get(['row2', 'col2'], 'bar'); // 'bar'
    • Returns the keys with the given value

      Parameters

      • value: V

        the value to inspect

      • Optionaldefaults: K[]

        the default keys if nothing matches the given value

      Returns undefined | K[]

      the keys with the given value

      map.getKey('bar');
      
    • Returns whether the map contains all the given keys

      Parameters

      • keys: K[][]

        the keys to check

      • exact: boolean = true

        whether matching entry values exactly

      Returns boolean

      whether the map contains all the given keys

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo']
      ]);
      map.hasAllKeys([['row1', 'col1'], ['row2', 'col2']]); // false
    • Returns whether the map contains all the given values

      Parameters

      • values: V[]

        the values to check

      Returns boolean

      whether the map contains all the given values

      map.hasAllValues(['foo']);
      
    • Returns whether the map contains any of the given keys

      Parameters

      • keys: K[][]

        the keys to check

      • exact: boolean = true

        whether matching entry values exactly

      Returns boolean

      whether the map contains any of the given keys

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo']
      ]);
      map.hasAnyKeys([['row1', 'col1'], ['row2', 'col2']]); // true
    • Returns whether the map contains any of the given values

      Parameters

      • values: V[]

        the values to check

      Returns boolean

      whether the map contains any of the given values

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo']
      ]);
      map.hasAnyValues(['foo', 'bar']); // true
    • Returns whether the map contains the given keys

      Parameters

      • keys: K[]

        the keys to check

      • exact: boolean = true

        whether matching entry values exactly

      Returns boolean

      whether the map contains the given key

      map.hasKey(['row1', 'col1']);
      
    • Returns whether the map contains the given keys/value pair

      Parameters

      • keys: K[]

        the keys to check

      • value: V

        the value to check

      Returns boolean

      whether the map contains the given keys/value pair

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo']
      ]);
      map.hasKeyValue(['row1', 'col1'], 'foo'); // true
      map.hasKeyValue(['row1', 'col1'], 'bar'); // false
    • Returns whether the map contains the given value

      Parameters

      • value: V

        the value to check

      Returns boolean

      whether the map contains the given value

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo']
      ]);
      map.hasValue('foo'); // true
      map.hasValue('bar'); // false
    • Returns whether the map is empty

      Returns boolean

      whether the map is empty

    • Returns whether the map is not empty

      Returns boolean

      whether the map is not empty

    • Returns the keys array of the map

      Returns K[][]

      the keys array of the map

    • Sets the value of the given keys

      Parameters

      • keys: K[]

        the keys to set

      • value: V

        the value to set

      Returns void

      map.set(['row1', 'col1'], 'bar');
      
    • Returns the string representation of the map elements

      Returns string

      the string representation of the map elements

      const map = MultiKeyMap.of([
      [['row1', 'col1'], 'foo'],
      [['row2', 'col2'], 'bar']
      ]);
      console.log(map.toString()); // '[row1,col1]:foo;[row2,col2]:bar'
    • Returns the values of the map

      Returns V[]

      the values of the map