tur/mutmap
MutableMap[K V]: mutable open-addressed hash table.
Since: Phase F5
MutableMap
(defstruct MutableMap [K V])
parameterized in-place hash table with key K, value V.
Since: Phase F5 (cross-plan-followups)
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
mutmap-len
(mutmap-len [m :int])
live entry count (excludes tombstones).
| m | MutableMap[K V] |
Number of live (key, value) entries.
(mutmap-len mm) ; => 0
Since: Phase F5
mutmap-set!
(mutmap-set! [m :int h :int key :int val :int])
insert or update (key, value). Mutates m in place.
| m | MutableMap[K V] | |
| h | precomputed hash of key (Hash[K]) | |
| key | key | |
| val | value |
nil.
(mutmap-set! mm 1 1 100)
Since: Phase F5
mutmap-get
(mutmap-get [m :int h :int key :int])
look up the value bound to key, or 0 if absent.
| m | MutableMap[K V] | |
| h | precomputed hash of key (Hash[K]) | |
| key | key |
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
mutmap-has?
(mutmap-has? [m :int h :int key :int])
check whether key is present.
| m | MutableMap[K V] | |
| h | precomputed hash of key | |
| key | key |
true if key is present (value of any kind), false otherwise.
(mutmap-has? mm 1 1) ; => true
Since: Phase F5
mutmap-delete!
(mutmap-delete! [m :int h :int key :int])
remove (key, value) if present. Mutates m
| m | MutableMap[K V] | |
| h | precomputed hash of key | |
| key | key |
true if key was present (and is now removed), false otherwise.
(mutmap-delete! mm 1 1) ; => true
Since: Phase F5
mutmap-eq?
(mutmap-eq? [m1 :int m2 :int val-cmp])
structural equality. Two MutableMap[K V]s are
| m1 | MutableMap[K V] | |
| m2 | MutableMap[K V] | |
| val-cmp | comparator 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
mutmap-free
(mutmap-free [m :int])
free the storage and wrapper.
| m | MutableMap[K V] to free |
(mutmap-free mm)
Since: Phase F5
Eq[MutableMap]
(definstance Eq [MutableMap])
structural equality using the value type's Eq.