Package 

Class CountingLruMap


  • @ThreadSafe() 
    public class CountingLruMap<K, V>
    
                        

    Map that keeps track of the elements order (according to the LRU policy) and their size.

    • Method Summary

      Modifier and Type Method Description
      synchronized int getCount() Gets the count of the elements in the map.
      synchronized int getSizeInBytes() Gets the total size in bytes of the elements in the map.
      synchronized K getFirstKey() 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 boolean contains(K key) Returns whether the map contains an element with the given key.
      synchronized V get(K key) Gets the element from the map.
      synchronized V put(K key, V value) Adds the element to the map, and removes the old element with the same key if any.
      synchronized V remove(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 void resetSize()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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.

      • contains

         synchronized boolean contains(K key)

        Returns whether the map contains an element with the given key.

      • get

        @Nullable() synchronized V get(K key)

        Gets the element from the map.

      • 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.

      • remove

        @Nullable() synchronized V remove(K key)

        Removes the element from the map.