A map type

Type eqfn

type eqfn<K> = fn@(K, K) -> bool

Type 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.

Type hashmap

type hashmap<K, V> = chained::t<K, V>

Type set

type set<K> = hashmap<K, ()>

A convenience type to treat a hashmap as a set

Interface map

Method size

fn size() -> uint

Return the number of elements in the map

Method 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

Method contains_key

fn contains_key(K) -> bool

Returns true if the map contains a value for the specified key

Method get

fn get(K) -> V

Get the value for the specified key. Fails if the key does not exist in the map.

Method []

fn [](K) -> V

Like get, but as an operator.

Method 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.

Method 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.

Method clear

fn clear()

Clear the map, removing all key/value pairs.

Method each

fn each(fn(K, V) -> bool)

Iterate over all the key/value pairs in the map

Method each_key

fn each_key(fn(K) -> bool)

Iterate over all the keys in the map

Method each_value

fn each_value(fn(V) -> bool)

Iterate over all the values in the map

Implementation hashmap of map<K, V> for t<K, V>

Method size

fn size() -> uint

Method contains_key

fn contains_key(k: K) -> bool

Method insert

fn insert(+k: K, +v: V) -> bool

Method find

fn find(k: K) -> option<V>

Method get

fn get(k: K) -> V

Method []

fn [](k: K) -> V

Method remove

fn remove(k: K) -> option<V>

Method clear

fn clear()

Method each

fn each(blk: fn(K, V) -> bool)

Method each_key

fn each_key(blk: fn(K) -> bool)

Method each_value

fn each_value(blk: fn(V) -> bool)

Function box_str_hash

fn box_str_hash<V: copy>() -> hashmap<@str, V>

Construct a hashmap for boxed string keys

Function bytes_hash

fn bytes_hash<V: copy>() -> hashmap<~[u8], V>

Construct a hashmap for byte string keys

Function hash_from_bytes

fn hash_from_bytes<V: copy>(items: ~[(~[u8], V)]) -> hashmap<~[u8], V>

Construct a hashmap from a vector with byte keys

Function hash_from_ints

fn hash_from_ints<V: copy>(items: ~[(int, V)]) -> hashmap<int, V>

Construct a hashmap from a vector with int keys

Function hash_from_strs

fn hash_from_strs<V: copy>(items: ~[(str, V)]) -> hashmap<str, V>

Construct a hashmap from a vector with string keys

Function hash_from_uints

fn hash_from_uints<V: copy>(items: ~[(uint, V)]) -> hashmap<uint, V>

Construct a hashmap from a vector with uint keys

Function 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

Function hashmap

fn hashmap<K: const, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) ->
   hashmap<K, V>

Function int_hash

fn int_hash<V: copy>() -> hashmap<int, V>

Construct a hashmap for int keys

Function 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

Function str_hash

fn str_hash<V: copy>() -> hashmap<str, V>

Construct a hashmap for string keys

Function uint_hash

fn uint_hash<V: copy>() -> hashmap<uint, V>

Construct a hashmap for uint keys

Function vec_from_set

fn vec_from_set<T: copy>(s: set<T>) -> ~[T]

Convert a set into a vector.