No matching definitions.

tur/mutmap

stdlib/mutmap.tur

MutableMap[K V]: mutable open-addressed hash table.

Since: Phase F5

defstruct

MutableMap

(defstruct MutableMap [K V])

parameterized in-place hash table with key K, value V.

Since: Phase F5 (cross-plan-followups)

defn

mutmap-new

(mutmap-new)

create a new empty MutableMap[K V] with default

An empty MutableMap[K V] pointer (int64 at the C level).

(mutmap-new)  ; => empty MutableMap

Since: Phase F5

defn

mutmap-len

(mutmap-len [m :int])

live entry count (excludes tombstones).

mMutableMap[K V]

Number of live (key, value) entries.

(mutmap-len mm)  ; => 0

Since: Phase F5

defn

mutmap-set!

(mutmap-set! [m :int h :int key :int val :int])

insert or update (key, value). Mutates m in place.

mMutableMap[K V]
hprecomputed hash of key (Hash[K])
keykey
valvalue

nil.

(mutmap-set! mm 1 1 100)

Since: Phase F5

defn

mutmap-get

(mutmap-get [m :int h :int key :int])

look up the value bound to key, or 0 if absent.

mMutableMap[K V]
hprecomputed hash of key (Hash[K])
keykey

The bound value, or 0 if key is not present. Callers needing to distinguish "absent" from "value = 0" should use mutmap-has? first.

(mutmap-get mm 1 1)  ; => 100

Since: Phase F5

defn

mutmap-has?

(mutmap-has? [m :int h :int key :int])

check whether key is present.

mMutableMap[K V]
hprecomputed hash of key
keykey

true if key is present (value of any kind), false otherwise.

(mutmap-has? mm 1 1)  ; => true

Since: Phase F5

defn

mutmap-delete!

(mutmap-delete! [m :int h :int key :int])

remove (key, value) if present. Mutates m

mMutableMap[K V]
hprecomputed hash of key
keykey

true if key was present (and is now removed), false otherwise.

(mutmap-delete! mm 1 1)  ; => true

Since: Phase F5

defn

mutmap-eq?

(mutmap-eq? [m1 :int m2 :int val-cmp])

structural equality. Two MutableMap[K V]s are

m1MutableMap[K V]
m2MutableMap[K V]
val-cmpcomparator fn [a :int b :int] :bool for values

true iff m1 and m2 have the same set of (key, value) pairs.

(mutmap-eq? ma mb (fn [a b] (= a b)))

Since: Phase F5

defn

mutmap-free

(mutmap-free [m :int])

free the storage and wrapper.

mMutableMap[K V] to free
(mutmap-free mm)

Since: Phase F5

definstance

Eq[MutableMap]

(definstance Eq [MutableMap])

structural equality using the value type's Eq.