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_map
  • user::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]

pub fn with_capacity(capacity: usize) -> Self[src]

pub fn with_capacity_and_hasher(
    capacity: usize,
    hash_builder: BuildHasher
) -> Self
[src]

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]

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> 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> 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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,