module std::mapsource
The hash map.
Map<K, V> takes any key type satisfying std::hash::Key: every primitive
type, String, every enum and struct whose parts are keys, and the types
declaring it. It keeps its entries densely
in insertion order in a Vector, so iterating them is a walk over one
array, and indexes them with an open-addressing table of 64-bit slots
probed linearly: a slot holds 32 bits of the key's hash above the
entry's position plus one, 0 marking an empty slot, so a probe compares
hashes before it touches an entry. The table is kept at most half full
and removal shifts the following slots back, so no tombstones
accumulate. Removing an entry moves the last one into its place, which
changes the iteration order. A map with String keys also takes &[u8]
keys, so looking text up needs no String. Maps of disposable values are
disposable themselves (section 5.2).
EntrydisposeMapMap::emptydisposelengthentriesinsertgetget_vartry_gettry_get_varcontainsremoveclearinsertgetget_vartry_gettry_get_varcontainsremove
type Entrysource
exp type Entry<K, V> : Disposable if (V: Disposable) = struct
One key and its value, as a map's entries() gives them.
Fields
exp key: Kexp value: V
Functions
fn disposesource
exp fn dispose<K, V: Disposable>(self entry: &var Entry<K, V>)
type Mapsource
exp type Map<K: Key, V> : Disposable if (V: Disposable) = struct
Functions
exp fn Map::empty() -> Map<K, V>exp fn dispose<K: Key, V: Disposable>(self map: &var Map<K, V>)exp fn length<K: Key, V>(self map: &Map<K, V>) -> u64exp fn entries<K: Key, V>(self map: &Map<K, V>) -> &[Entry<K, V>]exp fn insert<K: Key, V>(self map: &var Map<K, V>, key: K, value: V) -> Option<V>exp fn get<K: Key, V>(self map: &Map<K, V>, key: &K) -> &Vexp fn get_var<K: Key, V>(self map: &var Map<K, V>, key: &K) -> &var Vexp fn try_get<K: Key, V>(self map: &Map<K, V>, key: &K) -> Option<&V>exp fn try_get_var<K: Key, V>(self map: &var Map<K, V>, key: &K) -> Option<&var V>exp fn contains<K: Key, V>(self map: &Map<K, V>, key: &K) -> boolexp fn remove<K: Key, V>(self map: &var Map<K, V>, key: &K) -> Option<V>exp fn clear<K: Key, V>(self map: &var Map<K, V>)exp fn insert<V>(self map: &var Map<String, V>, key: &[u8], value: V) -> Option<V>exp fn get<V>(self map: &Map<String, V>, key: &[u8]) -> &Vexp fn get_var<V>(self map: &var Map<String, V>, key: &[u8]) -> &var Vexp fn try_get<V>(self map: &Map<String, V>, key: &[u8]) -> Option<&V>exp fn try_get_var<V>(self map: &var Map<String, V>, key: &[u8]) -> Option<&var V>exp fn contains<V>(self map: &Map<String, V>, key: &[u8]) -> boolexp fn remove<V>(self map: &var Map<String, V>, key: &[u8]) -> Option<V>
fn Map::emptysource
exp fn Map::empty() -> Map<K, V>
An empty map, allocating nothing.
fn disposesource
exp fn dispose<K: Key, V: Disposable>(self map: &var Map<K, V>)
fn lengthsource
exp fn length<K: Key, V>(self map: &Map<K, V>) -> u64
The number of entries.
fn entriessource
exp fn entries<K: Key, V>(self map: &Map<K, V>) -> &[Entry<K, V>]
The entries in insertion order, as long as none is removed.
fn insertsource
exp fn insert<K: Key, V>(self map: &var Map<K, V>, key: K, value: V) -> Option<V>
Gives the key the value and returns the value it replaces, if any.
fn getsource
exp fn get<K: Key, V>(self map: &Map<K, V>, key: &K) -> &V
The key's value in place; a fault when the map holds no such key.
fn get_varsource
exp fn get_var<K: Key, V>(self map: &var Map<K, V>, key: &K) -> &var V
The key's value in place for writing; a fault when the map holds no such key.
fn try_getsource
exp fn try_get<K: Key, V>(self map: &Map<K, V>, key: &K) -> Option<&V>
The key's value in place, or None.
fn try_get_varsource
exp fn try_get_var<K: Key, V>(self map: &var Map<K, V>, key: &K) -> Option<&var V>
The key's value in place for writing, or None.
fn containssource
exp fn contains<K: Key, V>(self map: &Map<K, V>, key: &K) -> bool
fn removesource
exp fn remove<K: Key, V>(self map: &var Map<K, V>, key: &K) -> Option<V>
Removes the key and returns its value, or None when absent.
fn clearsource
exp fn clear<K: Key, V>(self map: &var Map<K, V>)
Removes every entry, keeping the allocations.
fn insertsource
exp fn insert<V>(self map: &var Map<String, V>, key: &[u8], value: V) -> Option<V>
Gives the text the value and returns the value it replaces, if any; a new key is copied into a String.
fn getsource
exp fn get<V>(self map: &Map<String, V>, key: &[u8]) -> &V
fn get_varsource
exp fn get_var<V>(self map: &var Map<String, V>, key: &[u8]) -> &var V
fn try_getsource
exp fn try_get<V>(self map: &Map<String, V>, key: &[u8]) -> Option<&V>
fn try_get_varsource
exp fn try_get_var<V>(self map: &var Map<String, V>, key: &[u8]) -> Option<&var V>
fn containssource
exp fn contains<V>(self map: &Map<String, V>, key: &[u8]) -> bool
fn removesource
exp fn remove<V>(self map: &var Map<String, V>, key: &[u8]) -> Option<V>