Skip to main content

PassAgedCache

Struct PassAgedCache 

Source
pub struct PassAgedCache<K, V> { /* private fields */ }
Expand description

A bounded LRU cache whose entries also leave once IDLE_PASSES layout passes go by without a lookup of them. A scrolling list then keeps the measurements of the texts it shows, not of every text it has shown up to the bound.

Implementations§

Source§

impl<K, V> PassAgedCache<K, V>
where K: Eq + Hash,

Source

pub fn with_capacity_at_least_one(capacity: usize) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear(&mut self)

Drops every entry and gives back the storage they took.

Source

pub fn get<Q>(&mut self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

The value under key, marked used in the current pass.

Source

pub fn push(&mut self, key: K, value: V) -> Option<(K, V)>

Stores value under key, returning the entry it replaced or the least recently used one it pushed out.

Source

pub fn pop_lru(&mut self) -> Option<(K, V)>

Source

pub fn begin_pass(&mut self, dropped: impl FnMut(V))

Starts a layout pass: drops the entries no lookup asked for in the last IDLE_PASSES passes, least recently used first, handing each dropped value to dropped. It stops at the first entry still in use, so it costs one comparison when nothing has gone idle.

Auto Trait Implementations§

§

impl<K, V> Freeze for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: Freeze,

§

impl<K, V> RefUnwindSafe for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: RefUnwindSafe,

§

impl<K, V> Send for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: Send,

§

impl<K, V> Sync for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: Sync,

§

impl<K, V> Unpin for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: Unpin,

§

impl<K, V> UnsafeUnpin for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: UnsafeUnpin,

§

impl<K, V> UnwindSafe for PassAgedCache<K, V>
where BoundedLruCache<K, Used<V>>: UnwindSafe,

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

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

fn try_from(value: U) -> Result<T, !>

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.