Class LRUMap<KEYTYPE,VALUETYPE>
java.lang.Object
java.util.AbstractMap<KEYTYPE,VALUETYPE>
java.util.HashMap<KEYTYPE,VALUETYPE>
java.util.LinkedHashMap<KEYTYPE,VALUETYPE>
com.helger.commons.collection.impl.CommonsLinkedHashMap<KEYTYPE,VALUETYPE>
com.helger.commons.collection.map.LRUMap<KEYTYPE,VALUETYPE>
- Type Parameters:
KEYTYPE- Key typeVALUETYPE- Value type
- All Implemented Interfaces:
ICommonsMap<KEYTYPE,,VALUETYPE> ICommonsOrderedMap<KEYTYPE,,VALUETYPE> ICloneable<ICommonsMap<KEYTYPE,,VALUETYPE>> Serializable,Cloneable,Map<KEYTYPE,,VALUETYPE> SequencedMap<KEYTYPE,VALUETYPE>
- Direct Known Subclasses:
LoggingLRUMap
@NotThreadSafe
@UseDirectEqualsAndHashCode
public class LRUMap<KEYTYPE,VALUETYPE>
extends CommonsLinkedHashMap<KEYTYPE,VALUETYPE>
A special ordered map, that has an upper limit of contained elements. It is
therefore a "Last Recently Used" map.
- Author:
- Philip Helger
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetClone()final intinthashCode()protected voidonRemoveEldestEntry(int nSize, Map.Entry<KEYTYPE, VALUETYPE> aEldest) Protected method that is invoked every time the oldest entry is removed.protected final booleanremoveEldestEntry(Map.Entry<KEYTYPE, VALUETYPE> aEldest) toString()Methods inherited from class com.helger.commons.collection.impl.CommonsLinkedHashMap
createInstanceMethods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.collection.impl.ICommonsMap
addAll, containsAnyEntry, containsAnyKey, containsAnyValue, copyOfValues, copyOfValues, copyOfValuesMapped, copyOfValuesMapped, findFirstEntry, findFirstKey, findFirstValue, forEach, forEachKey, forEachKey, forEachValue, forEachValue, getAsUnmodifiable, getFirstEntry, getFirstEntry, getFirstKey, getFirstKey, getFirstValue, getFirstValue, getSortedByKey, getSortedByValue, getSwappedKeyValues, isNotEmpty, put, putAll, putAll, putAllMapped, putAllMapped, putAllMapped, putIf, putIfNotNull, removeAll, removeIf, removeIfKey, removeIfValue, removeObject, setAllMethods inherited from interface com.helger.commons.collection.impl.ICommonsOrderedMap
copyOfEntrySet, copyOfKeySet, copyOfKeySet, getLastKey, getLastKey, getLastValue, getLastValueMethods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Constructor Details
-
LRUMap
Create a new object with the specified max size.- Parameters:
nMaxSize- The maximum number of elements in this cache. May not be < 0.
-
LRUMap
-
-
Method Details
-
getClone
- Specified by:
getClonein interfaceICloneable<KEYTYPE>- Specified by:
getClonein interfaceICommonsOrderedMap<KEYTYPE,VALUETYPE> - Overrides:
getClonein classCommonsLinkedHashMap<KEYTYPE,VALUETYPE> - Returns:
- A 100% deep-copy of the implementing class.
-
getMaxSize
- Returns:
- The maximum number of elements that can reside inside this object. Never < 0.
-
onRemoveEldestEntry
@OverrideOnDemand protected void onRemoveEldestEntry(@Nonnegative int nSize, @Nonnull Map.Entry<KEYTYPE, VALUETYPE> aEldest) Protected method that is invoked every time the oldest entry is removed.- Parameters:
nSize- Current size of the map. Always ≥ 0.aEldest- The map entry that is removed. Nevernull.
-
removeEldestEntry
- Overrides:
removeEldestEntryin classLinkedHashMap<KEYTYPE,VALUETYPE>
-
equals
-
hashCode
public int hashCode() -
toString
- Overrides:
toStringin classAbstractMap<KEYTYPE,VALUETYPE>
-