-
@ThreadSafe() public class CountingLruMap<K, V>Map that keeps track of the elements order (according to the LRU policy) and their size.
-
-
Constructor Summary
Constructors Constructor Description CountingLruMap(ValueDescriptor<V> valueDescriptor)
-
Method Summary
Modifier and Type Method Description synchronized intgetCount()Gets the count of the elements in the map. synchronized intgetSizeInBytes()Gets the total size in bytes of the elements in the map. synchronized KgetFirstKey()Gets the key of the first element in the map. synchronized ArrayList<Map.Entry<K, V>>getMatchingEntries(@Nullable() Predicate<K> predicate)Gets the all matching elements. synchronized booleancontains(K key)Returns whether the map contains an element with the given key. synchronized Vget(K key)Gets the element from the map. synchronized Vput(K key, V value)Adds the element to the map, and removes the old element with the same key if any. synchronized Vremove(K key)Removes the element from the map. synchronized ArrayList<V>removeAll(@Nullable() Predicate<K> predicate)Removes all the matching elements from the map. synchronized ArrayList<V>clear()Clears the map. synchronized voidresetSize()-
-
Constructor Detail
-
CountingLruMap
CountingLruMap(ValueDescriptor<V> valueDescriptor)
-
-
Method Detail
-
getCount
synchronized int getCount()
Gets the count of the elements in the map.
-
getSizeInBytes
synchronized int getSizeInBytes()
Gets the total size in bytes of the elements in the map.
-
getFirstKey
@Nullable() synchronized K getFirstKey()
Gets the key of the first element in the map.
-
getMatchingEntries
synchronized ArrayList<Map.Entry<K, V>> getMatchingEntries(@Nullable() Predicate<K> predicate)
Gets the all matching elements.
-
contains
synchronized boolean contains(K key)
Returns whether the map contains an element with the given key.
-
put
@Nullable() synchronized V put(K key, V value)
Adds the element to the map, and removes the old element with the same key if any.
-
removeAll
synchronized ArrayList<V> removeAll(@Nullable() Predicate<K> predicate)
Removes all the matching elements from the map.
-
resetSize
synchronized void resetSize()
-
-
-
-