net.ontopia.utils
Class HistoryMap<T>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.Integer,T>
          extended by net.ontopia.utils.HistoryMap<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Integer,T>

public class HistoryMap<T>
extends java.util.HashMap<java.lang.Integer,T>

INTERNAL: Helper class for storing elements up to a certain amount, lower most elements will be removed to ensure a fixed size of the collection.

Since:
1.2.5
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  int maxEntries
           
protected  boolean suppressDuplicates
           
 
Constructor Summary
HistoryMap()
          Default constructor which uses 20 entries as the default history size and does suppress duplicates.
HistoryMap(int maxEntries, boolean suppressDuplicates)
          Constructor which allows to specify number of entries to store and duplicate suppression behaviour.
 
Method Summary
 void add(T obj)
           
 boolean doesSuppressDuplicates()
           
 java.util.Collection<T> getEntries()
           
 java.util.Collection getEntriesReverse()
           
 T getEntry(int index)
           
 int getMaxEntries()
           
 void removeEntry(T obj)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, 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
 

Field Detail

maxEntries

protected int maxEntries

suppressDuplicates

protected boolean suppressDuplicates
Constructor Detail

HistoryMap

public HistoryMap()
Default constructor which uses 20 entries as the default history size and does suppress duplicates.


HistoryMap

public HistoryMap(int maxEntries,
                  boolean suppressDuplicates)
Constructor which allows to specify number of entries to store and duplicate suppression behaviour.

Parameters:
maxEntries - Maxium number of entries to store in the history.
suppressDuplicates - Should suppress duplicate entries in map.
Method Detail

getMaxEntries

public int getMaxEntries()

doesSuppressDuplicates

public boolean doesSuppressDuplicates()

add

public void add(T obj)

removeEntry

public void removeEntry(T obj)

getEntry

public T getEntry(int index)

getEntries

public java.util.Collection<T> getEntries()

getEntriesReverse

public java.util.Collection getEntriesReverse()


Copyright © 2000-2012 Ontopia.