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 | Class and Description |
|---|---|
| protected static class | |
| protected static class | |
| protected static class | |
| protected abstract static class | |
| protected static class | |
| protected static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv transient AbstractLinkedMap. | header
Header in the linked list |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | AbstractLinkedMap(final int
the initial capacity, must be a power of two initialCapacity, final float the load factor, must be > 0.0f and generally < 1.0f loadFactor, final int the threshold, must be sensible threshold)Constructor which performs no validation on the passed in parameters. |
| protected | AbstractLinkedMap(final int
the initial capacity initialCapacity)Constructs a new, empty map with the specified initial capacity. |
| protected | AbstractLinkedMap(final int
the initial capacity initialCapacity, final float the load factor loadFactor)Constructs a new, empty map with the specified initial capacity and load factor. |
| protected | AbstractLinkedMap(final Map<? extends K, ? extends V>
the map to copy map)Constructor copying elements from another map. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addEntry(final AbstractHashedMap.
the entry to add entry,the index into the data array to store at hashIndex)Overrides org. |
| public void | clear()
Overrides org. Implements java. |
| public boolean | Returns: true if the map contains the valuethe value to search for value)Overrides org. Implements java. |
| protected AbstractLinkedMap. | Returns: the newly created entrythe next entry in sequence next,the hash code to use hashCode, final K the key to store key, final V the value to store value)Overrides org. |
| protected Iterator | Returns: the entrySet iteratorOverrides org. |
| protected Iterator | Returns: the keySet iteratorOverrides org. |
| protected Iterator | Returns: the values iteratorOverrides org. |
| protected AbstractLinkedMap. | Returns: theafter field of the entrythe entry to query, must not be null entryGets the |
| protected AbstractLinkedMap. | Returns: thebefore field of the entrythe entry to query, must not be null entryGets the |
| public K | Returns: the eldest keyImplements org. |
| protected AbstractLinkedMap. | getEntry(final Object
the key key)Overrides org. |
| protected AbstractLinkedMap. | Returns: the key at the specified indexthe index to retrieve index)Gets the key at the specified index. |
| protected void | init()
Overrides org. |
| public K | Returns: the most recently inserted keyImplements org. |
| public OrderedMapIterator | mapIterator()
Overrides org. Implements org. OrderedMapIterator over the map.
|
| public K | Returns: the next keythe key to get after key)Implements org. |
| public K | Returns: the previous keythe key to get before key)Implements org. |
| protected void | removeEntry(final AbstractHashedMap.
the entry to remove entry,the index into the data structure hashIndex, final AbstractHashedMap.the previous entry in the chain previousOverrides org. |