[src]

Struct collections::lru_cache::LruCache

pub struct LruCache<K, V> {
    // some fields omitted
}

An LRU Cache.

Methods

impl<K: Hash + TotalEq, V> LruCache<K, V>

fn new(capacity: uint) -> LruCache<K, V>

Create an LRU Cache that holds at most capacity items.

fn put(&mut self, k: K, v: V)

Put a key-value pair into cache.

fn get<'a>(&'a mut self, k: &K) -> Option<&'a V>

Return a value corresponding to the key in the cache.

fn pop(&mut self, k: &K) -> Option<V>

Remove and return a value corresponding to the key from the cache.

fn capacity(&self) -> uint

Return the maximum number of key-value pairs the cache can hold.

fn change_capacity(&mut self, capacity: uint)

Change the number of key-value pairs the cache can hold. Remove least-recently-used key-value pairs if necessary.

Trait Implementations

impl<A: Show + Hash + TotalEq, B: Show> Show for LruCache<A, B>

fn fmt(&self, f: &mut Formatter) -> Result

Return a string that lists the key-value pairs from most-recently used to least-recently used.

impl<K: Hash + TotalEq, V> Container for LruCache<K, V>

fn len(&self) -> uint

Return the number of key-value pairs in the cache.

impl<K: Hash + TotalEq, V> Mutable for LruCache<K, V>

fn clear(&mut self)

Clear the cache of all key-value pairs.

impl<K, V> Drop for LruCache<K, V>

fn drop(&mut self)