K - The map key type.V - The map value type.public class BoundedHashMap<K,V> extends LinkedHashMap<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_CAPACITY |
protected static float |
DEFAULT_LOAD_FACTOR |
| Constructor and Description |
|---|
BoundedHashMap()
Creates a BoundedHashMap with a capacity of 16, in insertion order mode.
|
BoundedHashMap(int capacity)
Creates a BoundedHashMap with a specified maximum capacity, in insertion order mode.
|
BoundedHashMap(int capacity,
boolean accessOrder)
Creates a BoundedHashMap with a specified maximum capacity and ordering mode.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCapacity()
Returns the maximum number of entries in the map.
|
protected static int |
getInitialCapacity(int capacity,
float loadFactor) |
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
protected void |
removeOverCapacityEntries()
Removes the first n entries in the map, where n is the number of entries in the map beyond its capacity.
|
void |
setCapacity(int capacity)
Sets the maximum number of entries in the map.
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeprotected static final int DEFAULT_CAPACITY
protected static final float DEFAULT_LOAD_FACTOR
public BoundedHashMap()
public BoundedHashMap(int capacity)
capacity - the maximum number of entries in the map.public BoundedHashMap(int capacity,
boolean accessOrder)
capacity - the maximum number of entries in the map.accessOrder - the ordering mode: true specifies access order, false specifies insertion order.public int getCapacity()
protected static int getInitialCapacity(int capacity,
float loadFactor)
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry in class LinkedHashMap<K,V>protected void removeOverCapacityEntries()
public void setCapacity(int capacity)
capacity - maximum number of entries in the map.