public abstract class LruBoundedCache<K,V>
extends java.lang.Object
This class is based on a Robin-Hood hashmap (http://www.sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/) with backshift (http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/).
The main modification compared to an RH hashmap is that it never grows the map (no rehashes) instead it is allowed to kick out entires that are considered old. The implementation tries to keep the map close to full, only evicting old entries when needed.
Constructor and Description |
---|
LruBoundedCache(int capacity,
int evictAgeThreshold,
scala.reflect.ClassTag<K> evidence$1,
scala.reflect.ClassTag<V> evidence$2) |
Modifier and Type | Method and Description |
---|---|
protected abstract V |
compute(K k) |
scala.Option<V> |
get(K k) |
V |
getOrCompute(K k) |
protected abstract int |
hash(K k) |
protected abstract boolean |
isCacheable(V v) |
protected int |
probeDistanceOf(int idealSlot,
int actualSlot) |
CacheStatistics |
stats() |
java.lang.String |
toString() |
public final CacheStatistics stats()
protected int probeDistanceOf(int idealSlot, int actualSlot)
protected abstract int hash(K k)
protected abstract boolean isCacheable(V v)
public java.lang.String toString()
toString
in class java.lang.Object