diff --git a/agb/src/hash_map.rs b/agb/src/hash_map.rs index 104d4f77..06db6181 100644 --- a/agb/src/hash_map.rs +++ b/agb/src/hash_map.rs @@ -171,6 +171,12 @@ impl HashMap { } } +impl Default for HashMap { + fn default() -> Self { + Self::new() + } +} + const fn fast_mod(len: usize, hash: HashType) -> usize { debug_assert!(len.is_power_of_two(), "Length must be a power of 2"); (hash as usize) & (len - 1) @@ -235,6 +241,13 @@ where .map(|location| &self.nodes.0[location].as_ref().unwrap().value) } + pub fn get_mut(&mut self, key: &K) -> Option<&mut V> { + let hash = self.hash(key); + + self.get_location(key, hash) + .map(|location| &mut self.nodes.0[location].as_mut().unwrap().value) + } + pub fn remove(&mut self, key: &K) -> Option { let hash = self.hash(key);