Class LRUCache<K,V>

Type Parameters:
K - the type of the map key, see Map.
V - the type of the map value, see Map.
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

public class LRUCache<K,V> extends LinkedHashMap<K,V>
An LRUCache with a fixed size and an access-order policy. Old mappings are automatically removed from the cache when new mappings are added. This implementation uses an LinkedHashMap internally.
See Also:
  • Constructor Details

    • LRUCache

      public LRUCache(int capacity)
      Parameters:
      capacity - the maximum capacity of this cache.
      Throws:
      IllegalArgumentException - if the capacity is negative.
  • Method Details