Entry

Struct Entry 

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

Source

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.

Source

pub fn peek_key(&self) -> &K

Silently read the key at this entry.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn remove(self) -> (K, V)

Remove this entry from the cache. Leaving the rest of the cache intact.

Runs in O(1) time.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a, K: Debug, V: Debug, R: Debug + Rng> Debug for Entry<'a, K, V, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, K, V, R> Freeze for Entry<'a, K, V, R>

§

impl<'a, K, V, R> RefUnwindSafe for Entry<'a, K, V, R>

§

impl<'a, K, V, R> Send for Entry<'a, K, V, R>
where R: Send, K: Send, V: Send,

§

impl<'a, K, V, R> Sync for Entry<'a, K, V, R>
where R: Sync, K: Sync, V: Sync,

§

impl<'a, K, V, R> Unpin for Entry<'a, K, V, R>

§

impl<'a, K, V, R = StdRng> !UnwindSafe for Entry<'a, K, V, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V