Package com.jackmeng.stl
Class stl_LRU_Cache<K,V>
java.lang.Object
com.jackmeng.stl.stl_LRU_Cache<K,V>
public class stl_LRU_Cache<K,V>
extends java.lang.Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classstl_LRU_Cache.Node<K,V> -
Field Summary
Fields Modifier and Type Field Description private intcapacityprivate stl_LRU_Cache.Node<K,V>[][]colorBlocksprivate java.util.Map<K,stl_LRU_Cache.Node<K,V>>mapprivate intnumColorsprivate stl_LRU_Cache.Node<K,V>tail -
Constructor Summary
Constructors Constructor Description stl_LRU_Cache(int capacity, int numColors, int blockSize) -
Method Summary
Modifier and Type Method Description private voidaddToFront(stl_LRU_Cache.Node<K,V> node, int color)private voidevict()Vget(K key)private intgetColor(K key)voidput(K key, V value)private voidremoveNode(stl_LRU_Cache.Node<K,V> node)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
capacity
private final int capacity -
map
-
tail
-
numColors
private final int numColors -
colorBlocks
-
-
Constructor Details
-
stl_LRU_Cache
public stl_LRU_Cache(int capacity, int numColors, int blockSize)
-
-
Method Details
-
get
-
put
-
evict
private void evict() -
removeNode
-
addToFront
-
getColor
-