added Map based on FnvHashMap, and AutoPermMap, generalized gal_el

This commit is contained in:
Jean-Philippe Bossuat
2025-01-16 16:08:22 +01:00
parent 7c8f2f3a63
commit 7c654d2464
10 changed files with 111 additions and 45 deletions

7
utils/Cargo.toml Normal file
View File

@@ -0,0 +1,7 @@
[package]
name = "utils"
version = "0.1.0"
edition = "2021"
[dependencies]
fnv = "1.0.7"

1
utils/src/lib.rs Normal file
View File

@@ -0,0 +1 @@
pub mod map;

20
utils/src/map.rs Normal file
View File

@@ -0,0 +1,20 @@
use fnv::FnvHashMap;
use std::hash::Hash;
pub struct Map<K, V>(pub FnvHashMap<K, V>);
impl<K: Eq + Hash, V> Map<K, V> {
pub fn new() -> Self {
Self {
0: FnvHashMap::<K, V>::default(),
}
}
pub fn insert(&mut self, k: K, data: V) -> Option<V> {
self.0.insert(k, data)
}
pub fn get(&self, k: &K) -> Option<&V> {
self.0.get(k)
}
}