Struct ccache::hashmap::SimpleHmap [−][src]
pub struct SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher = RandomState> where
Entry: EntryT<Key, Val, Cid, Umeta>,
Key: Hash,
Val: Val,
Cid: Cid,
Umeta: Meta<Val>,
BuildHasher: BuildHasher + Default, { /* fields omitted */ }
Simple, stable hashmap with indexes
This simple hashmap has some limitations:
- It will not resize
- It always has the same maximum size
- Should not be used in multithread
But it should be efficient enugh, and stable
So if you add or remove elements, the other will not be reshuffled at any time
It also supports O(1) access via indexes
Since it is built around user::EntryT
you can even add metadata
that will receive callbacks on get/insert operations, and you can combine
multiple caches and distinguish them via the user::Cid
In reimplementing the needed types, remember that:
user::EntryT
must have a default type that will be used as “empty-space” marker in the hash_mapuser::Cid
needs the default type which is used by EntryT to mark “empty-space”
Implementations
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
Entry: EntryT<Key, Val, Cid, Umeta>,
Key: Hash,
Val: Val,
Cid: Cid,
Umeta: Meta<Val>,
BuildHasher: BuildHasher + Default,
[src]
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
Entry: EntryT<Key, Val, Cid, Umeta>,
Key: Hash,
Val: Val,
Cid: Cid,
Umeta: Meta<Val>,
BuildHasher: BuildHasher + Default,
[src]pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn with_capacity_and_hasher(
capacity: usize,
hash_builder: BuildHasher
) -> Self
[src]
capacity: usize,
hash_builder: BuildHasher
) -> Self
pub fn capacity(&self) -> usize
[src]
pub fn len(&self) -> usize
[src]
pub fn get_full(&self, key: &Key) -> Option<(usize, &Entry)>
[src]
pub fn get_full_mut(&mut self, key: &Key) -> Option<(usize, &mut Entry)>
[src]
pub fn get_index(&self, idx: usize) -> Option<&Entry>
[src]
pub fn get_index_mut(&mut self, idx: usize) -> Option<&mut Entry>
[src]
pub fn remove(&mut self, item: &Entry) -> Entry
[src]
just mark the entry as not part of a Cid
and return a copy
don’t bother actually deleting the data
pub fn remove_idx(&mut self, idx: usize) -> Entry
[src]
just mark the entry as not part of a Cid
and return a copy
don’t bother actually deleting the data
If not present, return a default Entry
pub fn clear(&mut self)
[src]
pub fn insert(&mut self, entry: Entry) -> (Option<Entry>, usize, &Entry)
[src]
returns: any eventual clash in Option<Entry>
plus the index and a ref
to the actual entry.
If the hashmap is full and we can not insert the element, returns Err
pub fn insert_mut(&mut self, entry: Entry) -> (Option<Entry>, usize, &mut Entry)
[src]
pub fn hasher(&self) -> &BuildHasher
[src]
Trait Implementations
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> HashMap<Entry, Key, Val, Cid, Umeta, BuildHasher> for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
Entry: EntryT<Key, Val, Cid, Umeta>,
Key: Hash,
Val: Val,
Cid: Cid,
Umeta: Meta<Val>,
BuildHasher: BuildHasher + Default,
[src]
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> HashMap<Entry, Key, Val, Cid, Umeta, BuildHasher> for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
Entry: EntryT<Key, Val, Cid, Umeta>,
Key: Hash,
Val: Val,
Cid: Cid,
Umeta: Meta<Val>,
BuildHasher: BuildHasher + Default,
[src]fn with_capacity(capacity: usize) -> Self
[src]
fn with_capacity_and_hasher(capacity: usize, hash_builder: BuildHasher) -> Self
[src]
fn capacity(&self) -> usize
[src]
fn len(&self) -> usize
[src]
fn get_full(&self, key: &Key) -> Option<(usize, &Entry)>
[src]
fn get_full_mut(&mut self, key: &Key) -> Option<(usize, &mut Entry)>
[src]
fn get_index(&self, idx: usize) -> Option<&Entry>
[src]
fn get_index_mut(&mut self, idx: usize) -> Option<&mut Entry>
[src]
unsafe fn index_from_entry(&self, e: &Entry) -> usize
[src]
fn remove(&mut self, item: &Entry) -> Entry
[src]
fn remove_idx(&mut self, idx: usize) -> Entry
[src]
fn clear(&mut self)
[src]
fn insert(&mut self, entry: Entry) -> (Option<Entry>, usize, &Entry)
[src]
fn insert_mut(&mut self, entry: Entry) -> (Option<Entry>, usize, &mut Entry)
[src]
fn hasher(&self) -> &BuildHasher
[src]
Auto Trait Implementations
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> RefUnwindSafe for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: RefUnwindSafe,
Cid: RefUnwindSafe,
Entry: RefUnwindSafe,
Key: RefUnwindSafe,
Umeta: RefUnwindSafe,
Val: RefUnwindSafe,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> RefUnwindSafe for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: RefUnwindSafe,
Cid: RefUnwindSafe,
Entry: RefUnwindSafe,
Key: RefUnwindSafe,
Umeta: RefUnwindSafe,
Val: RefUnwindSafe,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> Send for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: Send,
Cid: Send,
Entry: Send,
Key: Send,
Umeta: Send,
Val: Send,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> Send for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: Send,
Cid: Send,
Entry: Send,
Key: Send,
Umeta: Send,
Val: Send,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> Sync for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: Sync,
Cid: Sync,
Entry: Sync,
Key: Sync,
Umeta: Sync,
Val: Sync,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> Sync for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: Sync,
Cid: Sync,
Entry: Sync,
Key: Sync,
Umeta: Sync,
Val: Sync,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> Unpin for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: Unpin,
Cid: Unpin,
Entry: Unpin,
Key: Unpin,
Umeta: Unpin,
Val: Unpin,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> Unpin for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: Unpin,
Cid: Unpin,
Entry: Unpin,
Key: Unpin,
Umeta: Unpin,
Val: Unpin,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> UnwindSafe for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: UnwindSafe,
Cid: UnwindSafe,
Entry: UnwindSafe,
Key: UnwindSafe,
Umeta: UnwindSafe,
Val: UnwindSafe,
impl<Entry, Key, Val, Cid, Umeta, BuildHasher> UnwindSafe for SimpleHmap<Entry, Key, Val, Cid, Umeta, BuildHasher> where
BuildHasher: UnwindSafe,
Cid: UnwindSafe,
Entry: UnwindSafe,
Key: UnwindSafe,
Umeta: UnwindSafe,
Val: UnwindSafe,