Struct ncollide2df64::util::hash_map::HashMap
pub struct HashMap<K, V, H> { // some fields omitted }
Alternative implementation of HashMap
.
It is different from std::hashmap::HashMap
because:
- the hash function can be personalized
- the hash table is separate from the data. Thus, the vector of entries is tight (no holes due to sparse hashing).
Methods
impl<K, V, H: HashFun<K>> HashMap<K, V, H>
fn new(h: H) -> HashMap<K, V, H>
Creates a new hash map.
fn new_with_capacity(capacity: uint, h: H) -> HashMap<K, V, H>
Creates a new hash map with a given capacity.
fn elements<'r>(&'r self) -> &'r [Entry<K, V>]
The elements added to this hash map.
This is a simple, contiguous array.
fn elements_mut<'r>(&'r mut self) -> &'r mut [Entry<K, V>]
The elements added to this hash map.
This is a simple, contiguous array.
impl<K: Eq + Clone, V, H: HashFun<K>> HashMap<K, V, H>
fn remove_elem_at(&mut self, at: uint) -> bool
Removes the element at the specified position of the element array.
If the index is greater than the table length, it returns false
.
impl<K: Eq, V, H: HashFun<K>> HashMap<K, V, H>
fn get_and_remove(&mut self, key: &K) -> Option<Entry<K, V>>
Removes an element and returns its value if it existed.
fn find_or_insert_lazy<'a>(&'a mut self, key: K, value: || -> V) -> &'a mut V
Same as self.insert_or_replace(key, value, false)
but with value
a function which is
called iff. the value does not exist yet.
fn insert_or_replace<'a>(&'a mut self, key: K, value: V, replace: bool) -> &'a mut V
Inserts or replace an element.
Arguments.
* `key` - key of the element to add.
* `value` - value to add.
* `replace` - if true the new value will replace the existing value. If false, the old
value is kept if it exists.
impl<K: Eq, V, H: HashFun<K>> HashMap<K, V, H>
fn insert(&mut self, key: K, value: V) -> bool
Inserts an element on the hash map.
fn remove(&mut self, key: &K) -> bool
Remove an element from the hash map.
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V>
Gets a mutable reference to an element of the hashmap.
Trait Implementations
impl<K: Clone, V: Clone, H: Clone> Clone for HashMap<K, V, H>
Automatically derived.
fn clone(&self) -> HashMap<K, V, H>
impl<__E: Encoder, K: Encodable<__E>, V: Encodable<__E>, H: Encodable<__E>> Encodable<__E> for HashMap<K, V, H>
Automatically derived.
fn encode(&self, __arg_0: &mut __E)
impl<__D: Decoder, K: Decodable<__D>, V: Decodable<__D>, H: Decodable<__D>> Decodable<__D> for HashMap<K, V, H>
Automatically derived.