[][src]Crate lfu

An efficient Least Frequently Used Cache implementation.

It supports insertions and retrievals, both of which are performed in constant time. In the event of tie between two least frequently used entries, the least recently used entry is evicted.

Examples

extern crate lfu;
use lfu::LFUCache;

let mut lfu = LFUCache::with_capacity(2).unwrap(); //initialize an lfu with a maximum capacity of 2 entries
lfu.set(2, 2);
lfu.set(3, 3);
lfu.set(3, 30);
lfu.set(4,4); //We're at fully capacity. First purge (2,2) since it's the least-frequently-used entry, then insert the current entry
assert_eq!(lfu.get(&2), None);
assert_eq!(lfu.get(&3), Some(&30));

Structs

LFUCache
LfuIterator