pub struct Lru<K: Ord + Clone, V> {
pub max_len: usize,
pub max_weight: u64,
/* private fields */
}Expand description
a least-recently-used map
Fields§
§max_len: usizeentries at most (0: no limit)
max_weight: u64summed weight at most (0: no limit)
Implementations§
Source§impl<K: Ord + Clone, V> Lru<K, V>
impl<K: Ord + Clone, V> Lru<K, V>
pub fn new(max_len: usize, max_weight: u64) -> Lru<K, V>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains(&self, k: &K) -> bool
Sourcepub fn get_mut(&mut self, k: &K) -> Option<&mut V>
pub fn get_mut(&mut self, k: &K) -> Option<&mut V>
an entry to change in place; it becomes the most recently used
Sourcepub fn insert(&mut self, k: K, v: V, weight: u64) -> Vec<(K, V)>
pub fn insert(&mut self, k: K, v: V, weight: u64) -> Vec<(K, V)>
stores an entry (replacing one with the same key) as the most recently used; the entries that had to go for the limits, oldest first
pub fn remove(&mut self, k: &K) -> Option<V>
pub fn clear(&mut self)
Trait Implementations§
impl<K: Eq + Ord + Clone, V: Eq> Eq for Lru<K, V>
impl<K: PartialEq + Ord + Clone, V: PartialEq> StructuralPartialEq for Lru<K, V>
Auto Trait Implementations§
impl<K, V> Forget for Lru<K, V>
impl<K, V> Freeze for Lru<K, V>
impl<K, V> RefUnwindSafe for Lru<K, V>
impl<K, V> Send for Lru<K, V>
impl<K, V> Sync for Lru<K, V>
impl<K, V> Unpin for Lru<K, V>
impl<K, V> UnsafeUnpin for Lru<K, V>
impl<K, V> UnwindSafe for Lru<K, V>
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