pub trait LruMap<Key, Value>: IntoIterator<Item = (Key, Value), IntoIter = IntoIter<Key, Value>> + EntryCache<Key, Value> + Sized {
    fn new(capacity: usize) -> Self;
    fn len(&self) -> usize;
    fn head(&mut self) -> Option<EntryRef<'_, Self, Key, Value>>;
    fn tail(&mut self) -> Option<EntryRef<'_, Self, Key, Value>>;
    fn iter(&self) -> Iter<'_, Key, Value>Notable traits for Iter<'a, Key, Value>impl<'a, Key, Value> Iterator for Iter<'a, Key, Value>    type Item = (&'a Key, &'a Value);;
    fn get<QueryKey>(&mut self, key: &QueryKey) -> Option<&Value>
    where
        QueryKey: Ord + Hash + Eq + ?Sized,
        Key: Borrow<QueryKey> + Ord + Hash + Eq
; fn get_without_update<QueryKey>(&self, key: &QueryKey) -> Option<&Value>
    where
        QueryKey: Ord + Hash + Eq + ?Sized,
        Key: Borrow<QueryKey> + Ord + Hash + Eq
; fn entry<QueryKey>(
        &mut self,
        key: &QueryKey
    ) -> Option<EntryRef<'_, Self, Key, Value>>
    where
        QueryKey: Ord + Hash + Eq + ?Sized,
        Key: Borrow<QueryKey> + Ord + Hash + Eq
; fn push(&mut self, key: Key, value: Value) -> Option<Removed<Key, Value>>; fn extend<IntoIter: IntoIterator<Item = (Key, Value)>>(
        &mut self,
        iterator: IntoIter
    ); fn is_empty(&self) -> bool { ... } }
Expand description

A Least Recently Used map interface that supports all map implementations exposed by this crate.

Required Methods

Creates a new map with the maximum capacity.

Panics

Panics if capacity is <= 1 or > u32::MAX.

Returns the number of keys present in this map.

Returns a reference to the most recently used key.

Returns a reference to the least recently used key.

Returns an iterator over the keys and values in order from most recently touched to least recently touched.

Returns the stored value for key, if present.

This function touches the key, making it the most recently used key.

Returns the stored value for key, if present.

This function does not touch the key, preserving its current position in the lru cache.

Returns an EntryRef for key, if present.

This function does not touch the key, preserving its current position in the lru cache. The EntryRef can touch the key, depending on which functions are used.

Inserts value for key into this map. If a value is already stored for this key, Removed::PreviousValue is returned with the previously stored value. If no value is currently stored and the map is full, the least recently used entry will be returned in Removed::Evicted. Otherwise, None will be returned.

This function touches the key, making it the most recently used key.

Pushes all items from iterator into this map. If there are more entries in the iterator than capacity remaining, keys will be evicted as needed.

This function is equivalent to a for loop calling Self::push().

Provided Methods

Retruns true if this map contains no keys.

Implementors