info.aduna.collections
Class LRUMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<K,V>
              extended by info.aduna.collections.LRUMap<K,V>
Type Parameters:
K - the type of the keys in the mapping
V - the type of the values in the mapping
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

public class LRUMap<K,V>
extends LinkedHashMap<K,V>

Map implementation providing an LRU algorithm and an optional maximum size. Based on java.util.LinkedHashMap.

Author:
Herko ter Horst
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
LRUMap()
           
LRUMap(int maxSize)
           
LRUMap(int maxSize, int initialCapacity)
           
LRUMap(int maxSize, int initialCapacity, float loadFactor)
           
LRUMap(Map<? extends K,? extends V> m)
           
 
Method Summary
 int getMaxSize()
           
protected  boolean removeEldestEntry(Map.Entry<K,V> entry)
           
 void setMaxSize(int i)
           
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

LRUMap

public LRUMap()

LRUMap

public LRUMap(int maxSize)

LRUMap

public LRUMap(int maxSize,
              int initialCapacity)

LRUMap

public LRUMap(int maxSize,
              int initialCapacity,
              float loadFactor)

LRUMap

public LRUMap(Map<? extends K,? extends V> m)
Method Detail

removeEldestEntry

protected boolean removeEldestEntry(Map.Entry<K,V> entry)
Overrides:
removeEldestEntry in class LinkedHashMap<K,V>

getMaxSize

public int getMaxSize()

setMaxSize

public void setMaxSize(int i)


Copyright © 1997-2008 Aduna. All Rights Reserved.