K
- The key type.V
- The value type.public class LRUMap<K,V>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
LRUMap.QItem<K,V> |
Constructor and Description |
---|
LRUMap() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(K key)
Check if this queue contains obj
|
static <K extends java.lang.Comparable<K>,V> |
createSafeMap()
Create a LRUMap that is safe to use with keys that can be
controlled by an attacker.
|
static <K,V> LRUMap<K,V> |
createSafeMap(java.util.Comparator<K> comparator)
Create a LRUMap that is safe to use with keys that can be
controlled by an attacker.
|
V |
get(K key)
Note that this does not automatically promote the key.
|
boolean |
isEmpty() |
java.util.Enumeration<K> |
keys() |
K |
peekKey() |
V |
peekValue() |
K |
popKey() |
V |
popValue() |
V |
push(K key,
V value)
push()ing an object that is already in
the queue moves that object to the most
recently used position, but doesn't add
a duplicate entry in the queue.
|
boolean |
removeKey(K key) |
int |
size() |
java.util.Enumeration<V> |
values() |
void |
valuesToArray(V[] entries)
Note that unlike the java.util versions, this will not reallocate (hence it doesn't return),
so pass in an appropriately big array, and make sure you hold the lock!
|
public static <K extends java.lang.Comparable<K>,V> LRUMap<K,V> createSafeMap()
public static <K,V> LRUMap<K,V> createSafeMap(java.util.Comparator<K> comparator)
public final V push(K key, V value)
public final K popKey()
public final V popValue()
public final V peekValue()
public final K peekKey()
public final int size()
public final boolean removeKey(K key)
public final boolean containsKey(K key)
obj
- Object to matchpublic final V get(K key)
public java.util.Enumeration<K> keys()
public java.util.Enumeration<V> values()
public boolean isEmpty()
public void valuesToArray(V[] entries)
entries
- public void clear()