public class AbstractLinkedMap extends AbstractHashedMap implements OrderedMap
This class implements all the features necessary for a subclass linked
hash-based map. Key-value entries are stored in instances of the
LinkEntry class which can be overridden and replaced.
The iterators can similarly be replaced, without the need to replace the KeySet,
EntrySet and Values view classes.
Overridable methods are provided to change the default hashing behaviour, and to change how entries are added to and removed from the map. Hopefully, all you need for unusual subclasses is here.
This implementation maintains order by original insertion, but subclasses
may work differently. The OrderedMap interface is implemented
to provide access to bidirectional iteration and extra convenience methods.
The orderedMapIterator() method provides direct access to a
bidirectional iterator. The iterators from the other views can also be cast
to OrderedIterator if required.
All the available iterators can be reset back to the start by casting to
ResettableIterator and calling reset().
The implementation is also designed to be subclassed, with lots of useful methods exposed.
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the map, resetting the size to zero and nullifying references
to avoid garbage collection issues.
|
boolean |
containsValue(java.lang.Object value)
Checks whether the map contains the specified value.
|
java.lang.Object |
firstKey()
Gets the first key in the map, which is the most recently inserted.
|
java.lang.Object |
lastKey()
Gets the last key in the map, which is the first inserted.
|
MapIterator |
mapIterator()
Gets an iterator over the map.
|
java.lang.Object |
nextKey(java.lang.Object key)
Gets the next key in sequence.
|
OrderedMapIterator |
orderedMapIterator()
Gets a bidirectional iterator over the map.
|
java.lang.Object |
previousKey(java.lang.Object key)
Gets the previous key in sequence.
|
public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.MapcontainsValue in class AbstractHashedMapvalue - the value to search forpublic void clear()
clear in interface java.util.Mapclear in class AbstractHashedMappublic java.lang.Object firstKey()
firstKey in interface OrderedMappublic java.lang.Object lastKey()
lastKey in interface OrderedMappublic java.lang.Object nextKey(java.lang.Object key)
nextKey in interface OrderedMapkey - the key to get afterpublic java.lang.Object previousKey(java.lang.Object key)
previousKey in interface OrderedMapkey - the key to get beforepublic MapIterator mapIterator()
A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object.
mapIterator in interface IterableMapmapIterator in class AbstractHashedMappublic OrderedMapIterator orderedMapIterator()
A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object.
orderedMapIterator in interface OrderedMapCopyright © 2010 - 2023 Adobe. All Rights Reserved