K - Key Type of this mapV - Value type of this mappublic class MaxSizeHashMap<K,V> extends LinkedHashMap<K,V>
HashMap. Whenever the size of this hashmap grows to it's maximum size,
It will automatically remove the oldest element from the map. The definition of the oldest element is either
can be determined by map entry time or access time.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor | Description |
|---|---|
MaxSizeHashMap(int maxSize) |
Constructor
|
| Modifier and Type | Method | Description |
|---|---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
Check the condition if the eldest element needed to be removed or not.
|
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, sizepublic MaxSizeHashMap(int maxSize)
maxSize - Maximum allowed size for this map. When size of this map grows to this value the oldest element will
automatically be removed.protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry in class LinkedHashMap<K,V>eldest - Eldest map element that is going to be removed.Copyright © 2025. All rights reserved.