Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HashMap<K, V>

Type parameters

  • K

  • V

Hierarchy

  • Map<K, V>
    • HashMap

Index

Constructors

constructor

  • new HashMap(hash: (key: K) => string): HashMap
  • Parameters

    • hash: (key: K) => string
        • (key: K): string
        • Parameters

          • key: K

          Returns string

    Returns HashMap

Properties

Readonly [Symbol.toStringTag]

[Symbol.toStringTag]: string

Readonly size

size: number

Static Map

Map: MapConstructor

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<[]>
  • Returns an iterable of entries in the map.

    Returns IterableIterator<[]>

clear

  • clear(): void
  • Returns void

delete

  • delete(key: K): boolean
  • Parameters

    • key: K

    Returns boolean

entries

  • entries(): IterableIterator<[]>
  • Returns an iterable of key, value pairs for every entry in the map.

    Returns IterableIterator<[]>

entryStream

  • entryStream<K2, V2>(): K extends K2 ? V extends V2 ? Stream<[]> : never : never
  • Returns a Stream for key-value tuple entries of this Map. Note: Alias of Stream.from(map)

    Type parameters

    • K2

    • V2

    Returns K extends K2 ? V extends V2 ? Stream<[]> : never : never

forEach

  • forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void
  • Parameters

    • callbackfn: (value: V, key: K, map: Map<K, V>) => void
        • (value: V, key: K, map: Map<K, V>): void
        • Parameters

          • value: V
          • key: K
          • map: Map<K, V>

          Returns void

    • Optional thisArg: any

    Returns void

get

  • get(key: K): undefined | V
  • Parameters

    • key: K

    Returns undefined | V

getOrDefault

  • getOrDefault<K2, V2>(key: K2, defaultGenerator: (key: K2) => V2)
  • getOrDefault<K2>(key: K2, defaultGenerator: (key: K2) => V, assign: true): V
  • If the given key is present in this map, returns the value associated with it. If the given key is not present, the defaultGenerator parameter is called and returned.

    Type parameters

    • K2: K

    • V2

    Parameters

    • key: K2

      The key.

    • defaultGenerator: (key: K2) => V2

      A function which will return the value for this key if it is not present.

        • (key: K2): V2
        • Parameters

          • key: K2

          Returns V2

  • If the given key is present in this map, returns the value associated with it. If the given key is not present, the defaultGenerator parameter is called and returned.

    Type parameters

    • K2: K

    Parameters

    • key: K2

      The key.

    • defaultGenerator: (key: K2) => V

      A function which will return the value for this key if it is not present.

        • (key: K2): V
        • Parameters

          • key: K2

          Returns V

    • assign: true

      Whether the generated default will be stored in the map.

    Returns V

has

  • has(key: K): boolean
  • Parameters

    • key: K

    Returns boolean

keyStream

  • keyStream<K2>(): K extends K2 ? Stream<K2> : never
  • Returns a Stream for the keys of this Map. Note: Alias of Stream.from(map.keys())

    Type parameters

    • K2

    Returns K extends K2 ? Stream<K2> : never

keys

  • keys(): IterableIterator<K>
  • Returns an iterable of keys in the map

    Returns IterableIterator<K>

retainWhere

  • retainWhere(predicate: (val: V, key: K) => any): boolean
  • retainWhere(key: K, predicate: (val: V, key: K) => any): boolean
  • Retains the entries from this map that match the given predicate function, any other entries will be deleted.

    Parameters

    • predicate: (val: V, key: K) => any

      A predicate that takes a key and a value, and returns a value which will be checked for truthiness.

        • (val: V, key: K): any
        • Parameters

          • val: V
          • key: K

          Returns any

    Returns boolean

    whether any entries remain.

  • If this map contains the given key, checks whether the entry matches the given predicate. If it does, it is kept. If not, it's deleted.

    Parameters

    • key: K
    • predicate: (val: V, key: K) => any

      A predicate that takes a key and a value, and returns a value which will be checked for truthiness.

        • (val: V, key: K): any
        • Parameters

          • val: V
          • key: K

          Returns any

    Returns boolean

    whether any entries remain in this map.

set

  • set(key: K, value: V): this
  • Parameters

    • key: K
    • value: V

    Returns this

toggle

  • toggle(has: boolean, key: K, value: V): this
  • Parameters

    • has: boolean
    • key: K
    • value: V

    Returns this

valueStream

  • valueStream(): Stream<V>
  • Returns a Stream for the values of this Map. Note: Alias of Stream.from(map.values())

    Returns Stream<V>

values

  • values(): IterableIterator<V>
  • Returns an iterable of values in the map

    Returns IterableIterator<V>

Generated using TypeDoc