TrieMap
Key-value hash maps.
An imperative hash map, with a general key and value type.
-
The
class
TrieMap
exposes the same interface asHashMap
. -
Unlike HashMap, the internal representation uses a functional representation (via
Trie
module). -
This class does not permit a direct
clone
operation (neither doesHashMap
), but it does permit creating iterators viaiter()
. Each iterator costsO(1)
to create, but represents a fixed view of the mapping that does not interfere with mutations (it will not reflect subsequent insertions or mutations, if any).
TrieMap
class TrieMap<K, V>(isEq : (K, K) -> Bool, hashOf : K -> Hash.Hash)
put
func put(k : K, v : V)
Associate a key and value, overwriting any prior association for the key.
replace
func replace(k : K, v : V) : ?V
Put the key and value, and return the (optional) prior value for the key.
remove
func remove(k : K) : ?V
Delete and return the (optional) value associated with the given key.
keys
func keys() : I.Iter<K>
An Iter
over the keys.
Each iterator gets a persistent view of the mapping, independent of concurrent updates to the iterated map.
vals
func vals() : I.Iter<V>
An Iter
over the values.
Each iterator gets a persistent view of the mapping, independent of concurrent updates to the iterated map.
entries
func entries() : I.Iter<(K, V)>
Returns an Iter
over the entries.
Each iterator gets a persistent view of the mapping, independent of concurrent updates to the iterated map.