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>
impl<K, V> PassAgedCache<K, V>
pub fn with_capacity_at_least_one(capacity: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get<Q>(&mut self, key: &Q) -> Option<&V>
pub fn get<Q>(&mut self, key: &Q) -> Option<&V>
The value under key, marked used in the current pass.
Sourcepub fn push(&mut self, key: K, value: V) -> Option<(K, V)>
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.
pub fn pop_lru(&mut self) -> Option<(K, V)>
Sourcepub fn begin_pass(&mut self, dropped: impl FnMut(V))
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more