Class AbstractLRUMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
edu.pdx.cs410J.AbstractLRUMap<K,V>
All Implemented Interfaces:
Map<K,V>

public abstract class AbstractLRUMap<K,V> extends AbstractMap<K,V>
This is the abstract superclass of an "LRU Map". An LRU Map is a Java Map that has a bounded number of mappings. If a new mapping is added to an LRU Map that already has the maximum number of mappings, then the least recently used mapping is removed. An element is used when it is added to or gotten from the Map.
  • Field Details

    • capacity

      protected int capacity
      The maximum number of mappings that this map can hold
  • Constructor Details

    • AbstractLRUMap

      protected AbstractLRUMap(int capacity)
      Creates a new LRU Map that will hold a given number of mappings
      Parameters:
      capacity - The maximum number of mappings in this map
      Throws:
      IllegalArgumentException - capacity is negative
  • Method Details

    • getStudentNames

      public abstract List<String> getStudentNames()
      Returns the names of the students who implemented this LRU Map.
    • put

      public abstract V put(K key, V value)
      When a mapping is made in an LRU that already contains the maximum number of mappings, the Least Recently Used element is removed.
      Specified by:
      put in interface Map<K,V>
      Overrides:
      put in class AbstractMap<K,V>
    • get

      public abstract V get(Object key)
      Getting an element from a map marks the mapping as "used". Note that the type of key must be Object so that, after type erasure, it will be compatible with the pre-generic API.
      Specified by:
      get in interface Map<K,V>
      Overrides:
      get in class AbstractMap<K,V>
    • remove

      public abstract V remove(Object key)
      Removes the given key from this map. Note that the type of key must be Object so that, after type erasure, it will be compatible with the pre-generic API.
      Specified by:
      remove in interface Map<K,V>
      Overrides:
      remove in class AbstractMap<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> map)
      Specified by:
      putAll in interface Map<K,V>
      Overrides:
      putAll in class AbstractMap<K,V>
    • clear

      public abstract void clear()
      Specified by:
      clear in interface Map<K,V>
      Overrides:
      clear in class AbstractMap<K,V>