Package edu.pdx.cs410J
Class AbstractLRUMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
edu.pdx.cs410J.AbstractLRUMap<K,V>
- All Implemented Interfaces:
Map<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.-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
Modifier and TypeFieldDescriptionprotected int
The maximum number of mappings that this map can hold -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractLRUMap
(int capacity) Creates a new LRU Map that will hold a given number of mappings -
Method Summary
Modifier and TypeMethodDescriptionabstract void
clear()
abstract V
Getting an element from a map marks the mapping as "used".Returns the names of the students who implemented this LRU Map.abstract V
When a mapping is made in an LRU that already contains the maximum number of mappings, the Least Recently Used element is removed.void
abstract V
Removes the given key from this map.Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
capacity
The maximum number of mappings that this map can hold
-
-
Constructor Details
-
AbstractLRUMap
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
Returns the names of the students who implemented this LRU Map. -
put
When a mapping is made in an LRU that already contains the maximum number of mappings, the Least Recently Used element is removed. -
get
Getting an element from a map marks the mapping as "used". Note that the type ofkey
must beObject
so that, after type erasure, it will be compatible with the pre-generic API. -
remove
Removes the given key from this map. Note that the type ofkey
must beObject
so that, after type erasure, it will be compatible with the pre-generic API. -
putAll
-
clear
-