pub struct Entry<'a, K, V, R: Rng = StdRng> { /* private fields */ }
Expand description
A reference to an occupied entry in the cache.
Implementations§
Source§impl<'a, K: Eq + Hash, V, R: Rng> Entry<'a, K, V, R>
impl<'a, K: Eq + Hash, V, R: Rng> Entry<'a, K, V, R>
Sourcepub fn peek_key_value(&self) -> (&K, &V)
pub fn peek_key_value(&self) -> (&K, &V)
Read the key and value at the entry without touching the rest of the cache. This operation will hence not be taken into account when considering which elements are most commonly used.
Sourcepub fn peek_value(&self) -> &V
pub fn peek_value(&self) -> &V
Read the value at the entry without touching the rest of the cache. This operation will hence not be taken into account when considering which elements are most commonly used.
Sourcepub fn peek_key_value_mut(&mut self) -> (&K, &mut V)
pub fn peek_key_value_mut(&mut self) -> (&K, &mut V)
Read the entry mutably without touching the rest of the cache. This operation will not be taken into account when considering which elements are most commonly used.
Sourcepub fn peek_value_mut(&mut self) -> &mut V
pub fn peek_value_mut(&mut self) -> &mut V
Read the value mutably without touching the rest of the cache. This operation will not be taken into account when considering which elements are most commonly used.
Sourcepub fn peek_long(self) -> (&'a K, &'a mut V)
pub fn peek_long(self) -> (&'a K, &'a mut V)
Read the item at this entry and destroy the Entry
struct. The item
will still be in the cache but this allows us to get a reference
with the full lifetime of this entry.
Sourcepub fn get_key_value(&mut self) -> (&K, &mut V)
pub fn get_key_value(&mut self) -> (&K, &mut V)
Get the key and value at this entry and promote this entry to a higher level in the cache.
This function will promote this entry to a higher level in the cache and based on some probability move other items down in the cache.
Sourcepub fn get_value(&mut self) -> &mut V
pub fn get_value(&mut self) -> &mut V
Get the value at this entry and promote this entry to a higher level in the cache.
This function will promote this entry to a higher level in the cache and based on some probability move other items down in the cache.
Sourcepub fn get_long(self) -> (&'a K, &'a mut V)
pub fn get_long(self) -> (&'a K, &'a mut V)
Get the key and value at this entry and promote this entry to a higher level in the cache.
Unlike Self::get_key_value
, this method consumes the Entry
allowing
for a longer lifetime of the returned reference. Note that the item
will still remain in the cache though.
This function will promote this entry to a higher level in the cache and based on some probability move other items down in the cache.
Sourcepub fn remove(self) -> (K, V)
pub fn remove(self) -> (K, V)
Remove this entry from the cache. Leaving the rest of the cache intact.
Runs in O(1) time.
Sourcepub fn index(self) -> Index<K, V, R>
pub fn index(self) -> Index<K, V, R>
Get an index for this entry.
This is like the Entry
without the reference to the cache. The Index
will be invalidated though if the cache is altered in any way,
including insertian of new elements or promotion of existing
elements.
Sourcepub fn index_and_cache(self) -> (Index<K, V, R>, &'a mut CommonCache<K, V, R>)
pub fn index_and_cache(self) -> (Index<K, V, R>, &'a mut CommonCache<K, V, R>)
Split this entry to an index and the cache.
The Index
is like the Entry
without the reference to the cache. The
Index
will be invalidated though if the cache is altered in any
way, including insertian of new elements or promotion of existing
elements.