K
- the type of keys maintained by this mapV
- the type of mapped valuespublic class MaxSizeLinkedHashMap<K,V> extends LinkedHashMap<K,V>
LinkedHashMap
with a maximum size. Adding an Entry
that would exceed this size
results in removing the eldest entry
.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
MaxSizeLinkedHashMap(int maxSize)
Constructs a MaxSizeLinkedHashMap with maximum size
maxSize . |
Modifier and Type | Method and Description |
---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public MaxSizeLinkedHashMap(int maxSize)
maxSize
.maxSize
- The maximum size for this MaxSizeLinkedHashMap.IllegalArgumentException
- if maxSize
is not positive.protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
This implementation will return true
if this MaxSizeLinkedHashMap has reached its maximum size, else false
.
removeEldestEntry
in class LinkedHashMap<K,V>
Copyright © 2006–2017 Icegreen Technologies. All rights reserved.