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]
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]
entries: usize,
extra_hashmap_capacity: usize,
hash_builder: HB
) -> LRU<'a, K, V, Umeta, HB>
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]
&mut self,
key: K,
val: V,
user_data: Umeta
) -> InsertResult<(K, V, Umeta)>
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> !RefUnwindSafe 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> 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>
impl<'a, K, V, Umeta, HB> !UnwindSafe for LRU<'a, K, V, Umeta, HB>