Package ghidra.util.datastruct
Class LRUMap<K,V>
- java.lang.Object
-
- ghidra.util.datastruct.LRUMap<K,V>
-
- Type Parameters:
K
- the key typeV
- the value type
- All Implemented Interfaces:
java.util.Map<K,V>
- Direct Known Subclasses:
LRUSet
public class LRUMap<K,V> extends java.lang.Object implements java.util.Map<K,V>
A LRU (Least Recently Used) map that maintains access-order (newest to oldest) iteration over the elements. This map is limited to the given size. As new items are added, the older items will be removed from this map.If you need to be notified of removals, then you can override
eldestEntryRemoved(java.util.Map.Entry)
.If you don't want the eldest removed, override
removeEldestEntry(java.util.Map.Entry)
and return false;If you would like to have the iteration order of your LRU structure be based upon access, but want it to iterate from least recently used to most recently used, then you should see
FixedSizeHashMap
.- See Also:
LinkedHashMap
,FixedSizeHashMap
-
-
Constructor Summary
Constructors Constructor Description LRUMap(int cacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
protected void
eldestEntryRemoved(java.util.Map.Entry<K,V> eldest)
This is called after an item has been removed from the cache.java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
boolean
isEmpty()
java.util.Set<K>
keySet()
V
put(K key, V value)
void
putAll(java.util.Map<? extends K,? extends V> m)
V
remove(java.lang.Object key)
protected boolean
removeEldestEntry(java.util.Map.Entry<K,V> eldest)
int
size()
java.lang.String
toString()
java.util.Collection<V>
values()
-
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
values
public java.util.Collection<V> values()
-
eldestEntryRemoved
protected void eldestEntryRemoved(java.util.Map.Entry<K,V> eldest)
This is called after an item has been removed from the cache.- Parameters:
eldest
- the ite being removed
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-