pub struct LruSlab<T> { /* private fields */ }
Expand description
A random-access table that maintains an LRU list in constant time
Implementations§
Source§impl<T> LruSlab<T>
impl<T> LruSlab<T>
Sourcepub fn with_capacity(capacity: u32) -> Self
pub fn with_capacity(capacity: u32) -> Self
Create an LruSlab
that can store at least capacity
elements without reallocating
Sourcepub fn vacant_key(&self) -> u32
pub fn vacant_key(&self) -> u32
The slot that will be returned by the next call to insert
, unless remove
is called first
Sourcepub fn insert(&mut self, value: T) -> u32
pub fn insert(&mut self, value: T) -> u32
Insert a value, returning the slot it was stored in
The returned slot is marked as the most recently used.
Sourcepub fn get_mut(&mut self, slot: u32) -> &mut T
pub fn get_mut(&mut self, slot: u32) -> &mut T
Mark slot
as the most recently used and access it uniquely
Trait Implementations§
Source§impl<T> FromIterator<T> for LruSlab<T>
impl<T> FromIterator<T> for LruSlab<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'a, T> IntoIterator for &'a LruSlab<T>
impl<'a, T> IntoIterator for &'a LruSlab<T>
Source§impl<'a, T> IntoIterator for &'a mut LruSlab<T>
impl<'a, T> IntoIterator for &'a mut LruSlab<T>
Auto Trait Implementations§
impl<T> Freeze for LruSlab<T>
impl<T> RefUnwindSafe for LruSlab<T>where
T: RefUnwindSafe,
impl<T> Send for LruSlab<T>where
T: Send,
impl<T> Sync for LruSlab<T>where
T: Sync,
impl<T> Unpin for LruSlab<T>
impl<T> UnwindSafe for LruSlab<T>where
T: 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