Class LRUMap<K,​V>

  • Type Parameters:
    K - type of the key
    V - type of the parameter
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<K,​V>

    public final class LRUMap<K,​V>
    extends java.util.LinkedHashMap<K,​V>
    A map with a fixed maximum size. The eldest entry will be removed when the maximum size is reached
    Since:
    3.0
    Author:
    Rodrygo Santos
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_SIZE
      DEFAULT_SIZE
    • Constructor Summary

      Constructors 
      Constructor Description
      LRUMap()
      default constructor
      LRUMap​(int _maxSize)
      constructor
      LRUMap​(java.lang.String sMaxSize)
      constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean removeEldestEntry​(java.util.Map.Entry<K,​V> eldest)  
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
    • Constructor Detail

      • LRUMap

        public LRUMap()
        default constructor
      • LRUMap

        public LRUMap​(java.lang.String sMaxSize)
        constructor
        Parameters:
        sMaxSize -
      • LRUMap

        public LRUMap​(int _maxSize)
        constructor
        Parameters:
        _maxSize -
    • Method Detail

      • removeEldestEntry

        protected boolean removeEldestEntry​(java.util.Map.Entry<K,​V> eldest)
        Overrides:
        removeEldestEntry in class java.util.LinkedHashMap<K,​V>