Package nom.tam.util
Class HashedList<VALUE extends CursorValue<String>>
java.lang.Object
nom.tam.util.HashedList<VALUE>
- Type Parameters:
VALUE
- value of the map
- All Implemented Interfaces:
Iterable<VALUE>
,Collection<VALUE>
public class HashedList<VALUE extends CursorValue<String>>
extends Object
implements Collection<VALUE>
a ordered hash map implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
HashedList.EntryComparator<VALUE extends CursorValue<String>>
private class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Add an element to the list at a specified position.boolean
boolean
addAll
(Collection<? extends VALUE> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
containsKey
(Object key) get
(int n) (package private) int
private boolean
internalRemove
(int index, VALUE entry) boolean
isEmpty()
iterator()
iterator
(int n) boolean
remove
(int index) Remove an object from the list giving the object index..boolean
boolean
removeAll
(Collection<?> c) boolean
Remove a keyed object from the list.boolean
replaceKey
(String oldKey, String newKey) Replace the key of a given element.boolean
retainAll
(Collection<?> c) int
size()
void
sort
(Comparator<String> comp) Sort the keys into some desired order.Object[]
toArray()
<T> T[]
toArray
(T[] o) toString()
private static boolean
unkeyedKey
(String key) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
ordered
An ordered list of the keys -
keyed
The key value pairs
-
-
Constructor Details
-
HashedList
public HashedList()
-
-
Method Details
-
add
Add an element to the list at a specified position. If that element was already in the list, it is first removed from the list then added again - if it was removed from a position before the position where it was to be added, that position is decremented by one.- Parameters:
pos
- The position at which the specified element is to be added. If pos is bigger than the size of the list the element is put at the end of the list.reference
- The element to add to the list.
-
unkeyedKey
-
add
- Specified by:
add
in interfaceCollection<VALUE extends CursorValue<String>>
-
addAll
- Specified by:
addAll
in interfaceCollection<VALUE extends CursorValue<String>>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<VALUE extends CursorValue<String>>
-
contains
- Specified by:
contains
in interfaceCollection<VALUE extends CursorValue<String>>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<VALUE extends CursorValue<String>>
-
containsKey
- Parameters:
key
- the key to search- Returns:
true
if the key is included in the list.
-
get
- Parameters:
n
- the index to get- Returns:
- the n'th entry from the beginning.
-
get
- Parameters:
key
- the key to search for- Returns:
- the value of a keyed entry. Non-keyed entries may be returned by requesting an iterator.
-
indexOf
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<VALUE extends CursorValue<String>>
-
iterator
- Specified by:
iterator
in interfaceCollection<VALUE extends CursorValue<String>>
- Specified by:
iterator
in interfaceIterable<VALUE extends CursorValue<String>>
- Returns:
- a HashedListIterator over the entire list.
-
iterator
- Parameters:
n
- the index to start the iterator- Returns:
- an iterator starting with the n'th entry.
-
iterator
- Parameters:
key
- the key to use as a start point- Returns:
- an iterator over the list starting with the entry with a given key.
-
remove
public boolean remove(int index) Remove an object from the list giving the object index..- Parameters:
index
- the index to remove- Returns:
- true if the index was in range
-
internalRemove
-
remove
- Specified by:
remove
in interfaceCollection<VALUE extends CursorValue<String>>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<VALUE extends CursorValue<String>>
-
removeKey
Remove a keyed object from the list. Unkeyed objects can be removed from the list using a HashedListIterator or using the remove(Object) method.- Parameters:
key
- the key to remove- Returns:
true
if the key was removed
-
replaceKey
Replace the key of a given element.- Parameters:
oldKey
- The previous key. This key must be present in the hash.newKey
- The new key. This key must not be present in the hash.- Returns:
- if the replacement was successful.
-
retainAll
- Specified by:
retainAll
in interfaceCollection<VALUE extends CursorValue<String>>
-
size
public int size()- Specified by:
size
in interfaceCollection<VALUE extends CursorValue<String>>
-
sort
Sort the keys into some desired order.- Parameters:
comp
- the comparator to use for the sorting
-
toArray
- Specified by:
toArray
in interfaceCollection<VALUE extends CursorValue<String>>
-
toArray
public <T> T[] toArray(T[] o) - Specified by:
toArray
in interfaceCollection<VALUE extends CursorValue<String>>
-
toString
-