java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
net.i2p.util.LHMCache<K,V>
- Type Parameters:
K- type of keys in this cacheV- type of values in this cache
- All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>, SequencedMap<K, V>
- Direct Known Subclasses:
EstablishmentManager.InboundTokens, UDPTransport.DestroyedCache
A LinkedHashMap with a maximum size, for use as an LRU cache. Unsynchronized.
- See Also:
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> Field Summary
FieldsConstructor Summary
ConstructorsMethod Summary
Public MethodsMethods inherited from class LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class HashMap
compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMap
equals, hashCode, toStringMethods inherited from interface SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
Field Details
_max
private final int _maxMaximum number of entries.
Constructor Details
LHMCache
public LHMCache(int max) Bounded cache with LRU eviction.- Parameters:
max- maximum entries before oldest are evicted
Method Details
clone
removeEldestEntry
Evict eldest when over capacity.- Overrides:
removeEldestEntryin classLinkedHashMap<K,V>