A map type
eqfn
hashfn
- A function that returns a hash of a valuehashmap
set
- A convenience type to treat a hashmap as a setmap
hashmap of map<K, V> for t<K, V>
box_str_hash
- Construct a hashmap for boxed string keysbytes_hash
- Construct a hashmap for byte string keyshash_from_bytes
- Construct a hashmap from a vector with byte keyshash_from_ints
- Construct a hashmap from a vector with int keyshash_from_strs
- Construct a hashmap from a vector with string keyshash_from_uints
- Construct a hashmap from a vector with uint keyshash_from_vec
- Construct a hashmap from a vectorhashmap
int_hash
- Construct a hashmap for int keysset_add
- Convenience function for adding keys to a hashmap with nil type keysstr_hash
- Construct a hashmap for string keysuint_hash
- Construct a hashmap for uint keysvec_from_set
- Convert a set into a vector.map::chained
eqfn
type eqfn<K> = fn@(K, K) -> bool
hashfn
type hashfn<K> = fn@(K) -> uint
A function that returns a hash of a value
The hash should concentrate entropy in the lower bits.
hashmap
type hashmap<K, V> = chained::t<K, V>
set
type set<K> = 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(+K, +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
contains_key
fn contains_key(K) -> bool
Returns true if the map contains a value for the specified key
get
fn get(K) -> V
Get the value for the specified key. Fails if the key does not exist in the map.
[]
fn [](K) -> V
Like get, but as an operator.
find
fn find(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(K) -> option<V>
Remove and return a value from the map. If the key does not exist in the map then returns none.
clear
fn clear()
Clear the map, removing all key/value pairs.
each
fn each(fn(K, V) -> bool)
Iterate over all the key/value pairs in the map
each_key
fn each_key(fn(K) -> bool)
Iterate over all the keys in the map
each_value
fn each_value(fn(V) -> bool)
Iterate over all the values in the map
hashmap of map<K, V> for t<K, V>
size
fn size() -> uint
contains_key
fn contains_key(k: K) -> bool
insert
fn insert(+k: K, +v: V) -> bool
find
fn find(k: K) -> option<V>
get
fn get(k: K) -> V
[]
fn [](k: K) -> V
remove
fn remove(k: K) -> option<V>
clear
fn clear()
each
fn each(blk: fn(K, V) -> bool)
each_key
fn each_key(blk: fn(K) -> bool)
each_value
fn each_value(blk: fn(V) -> bool)
box_str_hash
fn box_str_hash<V: copy>() -> hashmap<@str, V>
Construct a hashmap for boxed string keys
bytes_hash
fn bytes_hash<V: copy>() -> hashmap<~[u8], V>
Construct a hashmap for byte string keys
hash_from_bytes
fn hash_from_bytes<V: copy>(items: ~[(~[u8], V)]) -> hashmap<~[u8], V>
Construct a hashmap from a vector with byte keys
hash_from_ints
fn hash_from_ints<V: copy>(items: ~[(int, V)]) -> hashmap<int, V>
Construct a hashmap from a vector with int keys
hash_from_strs
fn hash_from_strs<V: copy>(items: ~[(str, V)]) -> hashmap<str, V>
Construct a hashmap from a vector with string keys
hash_from_uints
fn hash_from_uints<V: copy>(items: ~[(uint, V)]) -> hashmap<uint, V>
Construct a hashmap from a vector with uint keys
hash_from_vec
fn hash_from_vec<K: const copy,
V: copy>(hasher: hashfn<K>, eqer: eqfn<K>, items: ~[(K, V)])
-> hashmap<K, V>
Construct a hashmap from a vector
hashmap
fn hashmap<K: const, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) ->
hashmap<K, V>
int_hash
fn int_hash<V: copy>() -> hashmap<int, V>
Construct a hashmap for int keys
set_add
fn set_add<K: const copy>(set: set<K>, key: K) -> bool
Convenience function for adding keys to a hashmap with nil type keys
str_hash
fn str_hash<V: copy>() -> hashmap<str, V>
Construct a hashmap for string keys
uint_hash
fn uint_hash<V: copy>() -> hashmap<uint, V>
Construct a hashmap for uint keys
vec_from_set
fn vec_from_set<T: copy>(s: set<T>) -> ~[T]
Convert a set into a vector.