com.neoworks.util
Class SizeLimitedLinkedHashMap

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--java.util.LinkedHashMap
                    |
                    +--com.neoworks.util.SizeLimitedLinkedHashMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class SizeLimitedLinkedHashMap
extends java.util.LinkedHashMap

Size limited HashMap, where elements are held in a LinkedList, ordered as inserted.

Author:
Nigel Atkinson (nigel@neoworks.com)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
SizeLimitedLinkedHashMap(int maxSize)
          Public constructor
 
Method Summary
 int getMaxSize()
          Get the maximum number of elements
protected  boolean removeEldestEntry(java.util.Map.Entry eldest)
          Oldest element removal policy
 void setMaxSize(int maxSize)
          Set the maximum number of elements
 
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
equals, hashCode
 

Constructor Detail

SizeLimitedLinkedHashMap

public SizeLimitedLinkedHashMap(int maxSize)
Public constructor

Parameters:
maxSize - The maximum number of elements to hold
Method Detail

getMaxSize

public int getMaxSize()
Get the maximum number of elements

Returns:
The maximum number of elements

setMaxSize

public void setMaxSize(int maxSize)
Set the maximum number of elements

Parameters:
maxSize - The maximum number of elements

removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry eldest)
Oldest element removal policy

Overrides:
removeEldestEntry in class java.util.LinkedHashMap