ixfx
    Preparing search index...

    Interface IMapOfMutableExtended<V, M>

    Like a Map but multiple values can be stored for each key. Duplicate values can be added to the same or even a several keys.

    Three pre-defined MapOf's are available:

    Adding

    // Add one or more values using the predefined key function to generate a key
    map.addValue(value1, value2, ...);
    // Add one or more values under a specified key
    map.addKeyedValues(key, value1, value2, ...);

    Finding/accessing

    // Returns all values stored under key
    map.get(key);
    // Returns the first key where value is found, or _undefined_ if not found
    map.findKeyForValue(value);
    // Returns _true_ if value is stored under key
    map.hasKeyValue(key, value);
    // Returns _true_ if map contains key
    map.has(key);

    Removing

    // Removes everything
    map.clear();
    // Delete values under key. Returns _true_ if key was found.
    map.delete(key);
    // Deletes specified value under key. Returns _true_ if found.
    map.deleteKeyValue(key, value);

    Metadata about the map:

    map.isEmpty;         // True/false
    map.lengthMax; // Largest count of items under any key
    map.count(key); // Count of items stored under key, or 0 if key is not present.
    map.keys(); // Returns a string array of keys
    map.keysAndCounts(); // Returns an array of [string,number] for all keys and number of values for each key
    map.debugString(); // Returns a human-readable string dump of the contents

    Events can be listened to via addEventListener

    • addedKey, addedValue - when a new key is added, or when a new value is added
    • clear - when contents are cleared
    • deleteKey - when a key is deleted
    map.addEventLister(`addedKey`, ev => {
    // New key evt.key seen.
    });
    interface IMapOfMutableExtended<V, M> {
        get isDisposed(): boolean;
        get isEmpty(): boolean;
        get lengthKeys(): number;
        get typeName(): string;
        addEventListener<K extends keyof MapArrayEvents<V>>(
            name: K,
            listener: (
                event: MapArrayEvents<V>[K],
                sender: SimpleEventEmitter<MapArrayEvents<V>>,
            ) => void,
        ): void;
        addKeyedValues(key: string, ...values: readonly V[]): void;
        addValue(...values: readonly V[]): void;
        clear(): void;
        count(key: string): number;
        debugString(): string;
        delete(key: string): boolean;
        deleteByValue(value: V): boolean;
        deleteKeyValue(key: string, value: V): boolean;
        dispose(): void;
        entries(): IterableIterator<[key: string, value: V[]]>;
        entriesFlat(): IterableIterator<readonly [string, V]>;
        fireEvent<K extends keyof MapArrayEvents<V>>(
            type: K,
            args: MapArrayEvents<V>[K],
        ): void;
        firstKeyByValue(value: V, eq?: IsEqual<V>): undefined | string;
        get(key: string): IterableIterator<V>;
        has(key: string): boolean;
        hasKeyValue(key: string, value: V, eq?: IsEqual<V>): boolean;
        keys(): IterableIterator<string>;
        keysAndCounts(): IterableIterator<readonly [string, number]>;
        removeEventListener<K extends keyof MapArrayEvents<V>>(
            type: K,
            listener: (
                event: MapArrayEvents<V>[K],
                sender: SimpleEventEmitter<MapArrayEvents<V>>,
            ) => void,
        ): void;
        valuesFlat(): IterableIterator<V>;
    }

    Type Parameters

    • V

      Values stored under keys

    • M

      Type of data structure managing values

    Hierarchy (View Summary)

    Implemented by

    Index

    Accessors

    Methods