Package net.ontopia.topicmaps.nav2.utils
Class HistoryMap<T>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<Integer,T>
-
- net.ontopia.topicmaps.nav2.utils.HistoryMap<T>
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Integer,T>
public class HistoryMap<T> extends HashMap<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
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected int
maxEntries
protected boolean
suppressDuplicates
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T obj)
boolean
doesSuppressDuplicates()
Collection<T>
getEntries()
Collection
getEntriesReverse()
T
getEntry(int index)
int
getMaxEntries()
void
removeEntry(T obj)
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
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 Collection<T> getEntries()
-
getEntriesReverse
public Collection getEntriesReverse()
-
-