import Std.HashMap
Types
HashMap
type HashMap k v =
len: Usz
capacity: Usz
entries: Ptr (Entry k v)
A linear-scan mutable HashMap using a resize factor of 2.0
HashMap.len
HashMap.len (m: ref HashMap k v): Usz
Returns the length of this HashMap
HashMap.is_empty
HashMap.is_empty (m: ref HashMap k v): Bool
Returns true if this HashMap is empty. Equivalent to map.len () == 0
HashMap.empty
(HashMap.empty: fn Unit -> HashMap _ _ is pure) ()
Create a new, empty HashMap This will not allocate until the first entry is inserted.
HashMap.of
HashMap.of (s: s) {_: Stream s (k, v) e} {_: Hash k} {_: Eq k e}: HashMap k v can Panic, e
Create a HashMap containing each k, v pair from the given stream.
HashMap.extend
HashMap.extend (map: mut HashMap k v) (s: s) {_: Stream s (k, v) e} {_: Hash k} {_: Eq k e}: Unit can Panic, e
HashMap.clear
HashMap.clear (map: mut HashMap k v): Unit
HashMap.resize
HashMap.resize (map: mut HashMap k v) (new_capacity: Usz) {_: Hash k} {_: Eq k e}: Unit can Panic, e
HashMap.should_resize
HashMap.should_resize (map: ref HashMap k v): Bool
Should we resize this map when pushing another element?
HashMap.insert
HashMap.insert (map: mut HashMap k v) (key: k) (value: v) {_: Hash k} {_: Eq k e}: Maybe v can Panic, e
Inserts a key-value pair into the map, removing any item that may previously have been associated with the same key and returning the removed value if there was one.
HashMap.get_entry
HashMap.get_entry (map: ref 'm HashMap k v) (key: ref k) {_: Hash k} {eq: Eq k e}: Maybe (ref 'm Entry k v) can e
HashMap.get
HashMap.get (map: ref 'm HashMap k v) (key: ref k) {_: Hash k} {_: Eq k e}: ref 'm v can Fail, e
HashMap.contains
HashMap.contains (map: ref HashMap k v) (key: ref k) {_: Hash k} {_: Eq k e}: Bool can e
HashMap.remove
HashMap.remove (map: mut HashMap k v) (key: ref k) {_: Hash k} {_: Eq k e}: Maybe v can e
HashMap.keys
(HashMap.keys: fn (ref (HashMap k v)) -> (fn Unit [(ref (HashMap k v))] -> Unit can Emit k) is pure) (m: ref (HashMap k v))
Emit each key. Bit-copies the key; safe for Copy keys.
HashMap.values
(HashMap.values: fn (ref (HashMap k v)) -> (fn Unit [(ref (HashMap k v))] -> Unit can Emit v) is pure) (m: ref (HashMap k v))
Emit each value. Bit-copies the value; safe for Copy values.
HashMap.get_or_insert
HashMap.get_or_insert (m: mut HashMap k v) (key: k) (default: v) {_: Hash k} {_: Eq k e} {_: Copy k}: ref v can Panic, e
Return the existing value at key, or insert default and return it.
HashMap.get_or_insert_with
HashMap.get_or_insert_with (m: mut HashMap k v) (key: k) (mk: fn Unit [_] -> v) {_: Hash k} {_: Eq k e} {_: Copy k}: ref v can Panic, e
Same as get_or_insert but builds the default lazily.
HashMap.retain
HashMap.retain (m: mut HashMap k v) (pred: fn k v [_] -> Bool) {_: Copy k} {_: Copy v}: Unit
Remove every entry for which pred key value returns false.
HashMap.merge
HashMap.merge (dst: mut HashMap k v) (src: HashMap k v) {_: Hash k} {_: Eq k e}: Unit can Panic, e
Insert every entry from src into dst, overwriting on conflict.
Entry
type Entry k v =
key: k
value: v
occupied: Bool
tombstone: Bool