A map type
HashMap
Set
- A convenience type to treat a hashmap as a setMap
of Map<K, V> for @Mut<LinearMap<K, V>>
HashMap
hash_from_vec
- Construct a hashmap from a vectorset_add
- Convenience function for adding keys to a hashmap with nil type keysvec_from_set
- Convert a set into a vector.map::chained
map::util
HashMap
type HashMap<K: Eq IterBytes Hash, V> = chained::T<K, V>
Set
type Set<K: Eq IterBytes Hash> = HashMap<K, ()>
A convenience type to treat a hashmap as a set
Map
size
fn size() -> uint
Return the number of elements in the map
insert
fn insert(key: K, value: V) -> bool
Add a value to the map.
If the map already contains a value for the specified key then the original value is replaced.
Returns true if the key did not already exist in the map
update_with_key
fn update_with_key(key: K, newval: V, ff: &fn(K, V, V) -> V) -> bool
Add a value to the map.
If the map contains a value for the key, use the function to set a new value.
update
fn update(key: K, newval: V, ff: &fn(V, V) -> V) -> bool
Add a value to the map.
If the map contains a value for the key, use the function to set a new value. (Like insert_or_update_with_key
, but with a function of only values.)
contains_key
fn contains_key(key: K) -> bool
Returns true if the map contains a value for the specified key
contains_key_ref
fn contains_key_ref(key: &K) -> bool
Returns true if the map contains a value for the specified key, taking the key by reference.
get
fn get(key: K) -> V
Get the value for the specified key. Fails if the key does not exist in the map.
find
fn find(key: K) -> Option<V>
Get the value for the specified key. If the key does not exist in the map then returns none.
remove
fn remove(key: K) -> bool
Remove and return a value from the map. Returns true if the key was present in the map, otherwise false.
clear
fn clear()
Clear the map, removing all key/value pairs.
each
fn each(&fn(key: K, value: V) -> bool)
Iterate over all the key/value pairs in the map by value
each_key
fn each_key(&fn(key: K) -> bool)
Iterate over all the keys in the map by value
each_value
fn each_value(&fn(value: V) -> bool)
Iterate over all the values in the map by value
each_ref
fn each_ref(&fn(key: &K, value: &V) -> bool)
Iterate over all the key/value pairs in the map by reference
each_key_ref
fn each_key_ref(&fn(key: &K) -> bool)
Iterate over all the keys in the map by reference
each_value_ref
fn each_value_ref(&fn(value: &V) -> bool)
Iterate over all the values in the map by reference
Map<K, V>
for @Mut<LinearMap<K, V>>
size
fn size() -> uint
insert
fn insert(key: K, value: V) -> bool
contains_key
fn contains_key(key: K) -> bool
contains_key_ref
fn contains_key_ref(key: &K) -> bool
get
fn get(key: K) -> V
find
fn find(key: K) -> Option<V>
update_with_key
fn update_with_key(key: K, newval: V, ff: &fn(K, V, V) -> V) -> bool
update
fn update(key: K, newval: V, ff: &fn(V, V) -> V) -> bool
remove
fn remove(key: K) -> bool
clear
fn clear()
each
fn each(op: &fn(key: K, value: V) -> bool)
each_key
fn each_key(op: &fn(key: K) -> bool)
each_value
fn each_value(op: &fn(value: V) -> bool)
each_ref
fn each_ref(op: &fn(key: &K, value: &V) -> bool)
each_key_ref
fn each_key_ref(op: &fn(key: &K) -> bool)
each_value_ref
fn each_value_ref(op: &fn(value: &V) -> bool)
HashMap
fn HashMap<K: Eq IterBytes Hash Const, V: Copy>() -> HashMap<K, V>
hash_from_vec
fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>(items: &[(K, V)])
-> HashMap<K, V>
Construct a hashmap from a vector
set_add
fn set_add<K: Eq IterBytes Hash Const Copy>(set: Set<K>, key: K) -> bool
Convenience function for adding keys to a hashmap with nil type keys
vec_from_set
fn vec_from_set<T: Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T]
Convert a set into a vector.