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 class
stl_LRU_Cache.Node<K,V>
-
Field Summary
Fields Modifier and Type Field Description private int
capacity
private stl_LRU_Cache.Node<K,V>[][]
colorBlocks
private java.util.Map<K,stl_LRU_Cache.Node<K,V>>
map
private int
numColors
private 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 void
addToFront(stl_LRU_Cache.Node<K,V> node, int color)
private void
evict()
V
get(K key)
private int
getColor(K key)
void
put(K key, V value)
private void
removeNode(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
-