orx_v/sparse/impl_lookup/
hash_map.rs1use crate::Lookup;
2use core::hash::Hash;
3use std::collections::HashMap;
4
5impl<Idx: Eq + Hash, T> Lookup<Idx, T> for HashMap<Idx, T> {
6 #[inline(always)]
7 fn len(&self) -> usize {
8 HashMap::len(self)
9 }
10
11 #[inline(always)]
12 fn contains_key(&self, idx: &Idx) -> bool {
13 HashMap::contains_key(self, idx)
14 }
15
16 #[inline(always)]
17 fn get(&self, idx: &Idx) -> Option<&T> {
18 HashMap::get(self, idx)
19 }
20
21 #[inline(always)]
22 fn insert(&mut self, idx: Idx, value: T) {
23 HashMap::insert(self, idx, value);
24 }
25
26 #[inline(always)]
27 fn entry_or_insert(&mut self, idx: Idx, value: T) -> &mut T {
28 HashMap::entry(self, idx).or_insert(value)
29 }
30
31 fn values_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>
32 where
33 T: 'a,
34 {
35 self.values_mut()
36 }
37
38 fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = (&'a Idx, &'a mut T)>
39 where
40 T: 'a,
41 Idx: 'a,
42 {
43 self.iter_mut()
44 }
45
46 fn clear(&mut self) {
47 self.clear();
48 }
49}