orx_v/sparse/impl_lookup/
hash_map.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::Lookup;
use core::hash::Hash;
use std::collections::HashMap;

impl<Idx: Eq + Hash, T> Lookup<Idx, T> for HashMap<Idx, T> {
    #[inline(always)]
    fn len(&self) -> usize {
        HashMap::len(self)
    }

    #[inline(always)]
    fn contains_key(&self, idx: &Idx) -> bool {
        HashMap::contains_key(self, idx)
    }

    #[inline(always)]
    fn get(&self, idx: &Idx) -> Option<&T> {
        HashMap::get(self, idx)
    }

    #[inline(always)]
    fn insert(&mut self, idx: Idx, value: T) {
        HashMap::insert(self, idx, value);
    }

    #[inline(always)]
    fn entry_or_insert(&mut self, idx: Idx, value: T) -> &mut T {
        HashMap::entry(self, idx).or_insert(value)
    }

    fn values_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>
    where
        T: 'a,
    {
        self.values_mut()
    }

    fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = (&'a Idx, &'a mut T)>
    where
        T: 'a,
        Idx: 'a,
    {
        self.iter_mut()
    }

    fn clear(&mut self) {
        self.clear();
    }
}