Struct uluru::LRUCache
[−]
[src]
pub struct LRUCache<T, A: Array<Item = Entry<T>>> { /* fields omitted */ }
A LRU cache using a statically-sized array for storage.
The most-recently-used entry is at index head
. The entries form a linked list, linked to each
other by indices within the entries
array. After an entry is added to the array, its index
never changes, so these links are never invalidated.
Methods
impl<T, A: Array<Item = Entry<T>>> LRUCache<T, A>
[src]
fn num_entries(&self) -> usize
[src]
Returns the number of elements in the cache.
fn touch(&mut self, idx: CacheIndex)
[src]
Touch a given entry, putting it first in the list.
fn front(&self) -> Option<&T>
[src]
Returns the front entry in the list (most recently used).
fn front_mut(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the front entry in the list (most recently used).
fn iter(&self) -> LRUCacheIterator<T, A>
[src]
Iterate over the contents of this cache, from more to less recently used.
fn iter_mut(&mut self) -> LRUCacheMutIterator<T, A>
[src]
Iterate mutably over the contents of this cache.
fn lookup<F, R>(&mut self, test_one: F) -> Option<R> where
F: FnMut(&mut T) -> Option<R>,
[src]
F: FnMut(&mut T) -> Option<R>,
Performs a lookup on the cache with the given test routine. Touches the result on a hit.
fn insert(&mut self, val: T)
[src]
Insert a given key in the cache.
fn evict_all(&mut self)
[src]
Evict all elements from the cache.