psdi.util

Class LRUCache

  • java.lang.Object
    • java.util.AbstractMap
      • java.util.HashMap
        • java.util.LinkedHashMap
          • psdi.util.LRUCache
  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map


    public class LRUCache
    extends java.util.LinkedHashMap
    A class to represent a fixed size cache that implement the LRU algorithem.
    See Also:
    Serialized Form
    • Nested Class Summary

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

        java.util.AbstractMap.SimpleEntry, java.util.AbstractMap.SimpleImmutableEntry
    • Constructor Summary

      Constructors 
      Constructor and Description
      LRUCache(int initial, int limit) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear() 
      java.lang.Object clone() 
      java.util.Set entrySet() 
      java.lang.Object get(java.lang.Object key) 
      java.util.Set keySet() 
      java.lang.Object put(java.lang.Object key, java.lang.Object value) 
      void putAll(java.util.Map map) 
      java.lang.Object remove(java.lang.Object key) 
      protected boolean removeEldestEntry(java.util.Map.Entry eldest) 
      void setCapacity(int size) 
      • Methods inherited from class java.util.LinkedHashMap

        containsValue, forEach, getOrDefault, replaceAll, values
      • Methods inherited from class java.util.HashMap

        compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putIfAbsent, 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, putIfAbsent, remove, replace, replace, size
    • Constructor Detail

      • LRUCache

        public LRUCache(int initial,
                        int limit)
    • Method Detail

      • removeEldestEntry

        protected boolean removeEldestEntry(java.util.Map.Entry eldest)
        Overrides:
        removeEldestEntry in class java.util.LinkedHashMap
      • setCapacity

        public void setCapacity(int size)
      • get

        public java.lang.Object get(java.lang.Object key)
        Specified by:
        get in interface java.util.Map
        Overrides:
        get in class java.util.LinkedHashMap
      • put

        public java.lang.Object put(java.lang.Object key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map
        Overrides:
        put in class java.util.HashMap
      • putAll

        public void putAll(java.util.Map map)
        Specified by:
        putAll in interface java.util.Map
        Overrides:
        putAll in class java.util.HashMap
      • remove

        public java.lang.Object remove(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map
        Overrides:
        remove in class java.util.HashMap
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map
        Overrides:
        clear in class java.util.LinkedHashMap
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.util.HashMap
      • keySet

        public java.util.Set keySet()
        Specified by:
        keySet in interface java.util.Map
        Overrides:
        keySet in class java.util.LinkedHashMap
      • entrySet

        public java.util.Set entrySet()
        Specified by:
        entrySet in interface java.util.Map
        Overrides:
        entrySet in class java.util.LinkedHashMap