edu.pdx.cs399J
Class AbstractLRUMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by edu.pdx.cs399J.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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  int capacity
          The maximum number of mappings that this map can hold
 
Constructor Summary
protected AbstractLRUMap(int capacity)
          Creates a new LRU Map that will hold a given number of mappings
 
Method Summary
abstract  void clear()
           
abstract  V get(Object key)
          Getting an element from a map marks the mapping as "used".
abstract  List<String> getStudentNames()
          Returns the names of the students who implemented this LRU Map.
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.
 void putAll(Map<? extends K,? extends V> map)
           
abstract  V remove(Object key)
          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
 

Field Detail

capacity

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

Constructor Detail

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 Detail

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>


Copyright © 2000-2009 Portland State University. All Rights Reserved.