Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HashMap<K, V>

Configurable hash map implementation w/ ES6 Map API. Uses open addressing / linear probing to resolve key collisions. Supports any key types via mandatory user supplied hash function.

See HashMapOpts for further configuration & behavior details.

example
import { HashMap } from "@thi.ng/associative"
import { hash } from "@thi.ng/vectors"

m = new HashMap([], { hash })
m.set([1, 2], "a");
m.set([3, 4], "b");
m.set([1, 2], "c");
// HashMap { [ 1, 2 ] => 'c', [ 3, 4 ] => 'b' }

Type parameters

  • K

  • V

Hierarchy

  • Map<K, V>
    • HashMap

Implements

Index

Constructors

constructor

Properties

Static Map

Map: MapConstructor

Accessors

[Symbol.species]

[Symbol.toStringTag]

  • get [Symbol.toStringTag](): string

size

  • get size(): number

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<Pair<K, V>>

clear

  • clear(): void

copy

delete

  • delete(key: K): boolean

dissoc

  • dissoc(keys: Iterable<K>): this

empty

entries

  • entries(): IterableIterator<Pair<K, V>>

equiv

  • equiv(o: any): boolean

Protected find

forEach

  • forEach(fn: Fn3<V, K, Map<K, V>, void>, thisArg?: any): void
  • The key & value args given the callback fn MUST be treated as readonly/immutable. This could be enforced via TS, but would break ES6 Map interface contract.

    Parameters

    • fn: Fn3<V, K, Map<K, V>, void>
    • Optional thisArg: any

    Returns void

get

  • get(key: K, notFound?: V): V | undefined

has

  • has(key: K): boolean

into

  • into(pairs: Iterable<Pair<K, V>>): this

keys

  • keys(): IterableIterator<K>

opts

Protected resize

set

  • set(key: K, val: V): this

values

  • values(): IterableIterator<V>

Generated using TypeDoc