Struct ccache::lru::LRU[][src]

pub struct LRU<'a, K, V, Umeta, HB> where
    K: Hash,
    V: Val,
    Umeta: Meta<V>,
    HB: BuildHasher + Default
{ /* fields omitted */ }

LRU implementation that wraps LRUShared

note that we store the value as-is and we have pointers to those.

If you need to grow the LRU dynamically, make sure to use Box<V> as the value (resize currently not supported)

Implementations

impl<'a, K: Hash, V: Val, Umeta: Meta<V>, HB: BuildHasher + Default> LRU<'a, K, V, Umeta, HB>[src]

pub fn new(
    entries: usize,
    extra_hashmap_capacity: usize,
    hash_builder: HB
) -> LRU<'a, K, V, Umeta, HB>
[src]

Create a new empty LRU

pub fn insert(&mut self, key: K, val: V) -> InsertResult<(K, V, Umeta)>[src]

insert a new entry in the LRU

pub fn insert_with_meta(
    &mut self,
    key: K,
    val: V,
    user_data: Umeta
) -> InsertResult<(K, V, Umeta)>
[src]

The same insert, but with metadata

pub fn clear(&mut self)[src]

empty the whole LRU

pub fn remove(&mut self, key: &K) -> Option<(V, Umeta)>[src]

remove a single element from the lru

pub fn contains_key(&self, key: &K) -> bool[src]

chech if a key exists in the LRU

pub fn make_head(&mut self, key: &K) -> Option<(&V, &Umeta)>[src]

If present, make the entry the head of the LRU, and return references to the values

pub fn get(&mut self, key: &K) -> Option<(&V, &Umeta)>[src]

get references to an entry

pub fn get_mut(&mut self, key: &K) -> Option<(&mut V, &mut Umeta)>[src]

get a mutable reference to the entry

Auto Trait Implementations

impl<'a, K, V, Umeta, HB> !RefUnwindSafe for LRU<'a, K, V, Umeta, HB>

impl<'a, K, V, Umeta, HB> !Send for LRU<'a, K, V, Umeta, HB>

impl<'a, K, V, Umeta, HB> !Sync for LRU<'a, K, V, Umeta, HB>

impl<'a, K, V, Umeta, HB> Unpin for LRU<'a, K, V, Umeta, HB> where
    HB: Unpin,
    K: Unpin,
    Umeta: Unpin,
    V: Unpin

impl<'a, K, V, Umeta, HB> !UnwindSafe for LRU<'a, K, V, Umeta, HB>

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