Class LRUCache<K,​V>

    • Field Detail

      • maxCacheSize

        protected int maxCacheSize
    • Constructor Detail

      • LRUCache

        public LRUCache()
        Default constructor for an LRU Cache The default capacity is 10000
      • LRUCache

        public LRUCache​(int maximumCacheSize)
        Constructs a LRUCache with a maximum capacity
        maximumCacheSize -
      • LRUCache

        public LRUCache​(int initialCapacity,
                        int maximumCacheSize,
                        float loadFactor,
                        boolean accessOrder)
        Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
        initialCapacity - the initial capacity.
        maximumCacheSize -
        loadFactor - the load factor.
        accessOrder - the ordering mode - true for access-order, false for insertion-order.
        IllegalArgumentException - if the initial capacity is negative or the load factor is non-positive.
    • Method Detail

      • getMaxCacheSize

        public int getMaxCacheSize()
        Returns the maxCacheSize.
      • setMaxCacheSize

        public void setMaxCacheSize​(int maxCacheSize)
        maxCacheSize - The maxCacheSize to set.
      • onCacheEviction

        protected void onCacheEviction​(Map.Entry<K,​V> eldest)