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>
An ordered hash map implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends VALUE> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
containsKey
(Object key) Checks if the list contains an entry for the given keyword.cursor()
Return the iterator that represents the current position in the header.get
(int n) Returns the element for a given index from the odered list.Returns the element for the given hash key.boolean
isEmpty()
HashedList<VALUE>.nom.tam.util.HashedList.HashedListIterator
iterator()
Returns an iterator that will go over all elements of the list in the defined order.iterator
(int n) Returns an iterator, which starts from the specified entry index, and goes over the remaining elements in the list.HashedList<VALUE>.nom.tam.util.HashedList.HashedListIterator
Returns an iterator, which starts from the specified keyed entry, and goes over the remaining elements in the list.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()
void
Similar to add(VALUE), except this replaces an existing card that matches the specified key in-situ.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
HashedList
public HashedList()
-
-
Method Details
-
add
- Specified by:
add
in interfaceCollection<VALUE extends CursorValue<String>>
-
update
Similar to add(VALUE), except this replaces an existing card that matches the specified key in-situ. At the same time, new entries are added at the current position.- Parameters:
key
- The key of the existing card (if any) to be replaced).entry
- The element to add to the list.
-
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
Checks if the list contains an entry for the given keyword.- Parameters:
key
- the key to search- Returns:
true
if the key is included in the list, otherwisefalse
.
-
get
Returns the element for a given index from the odered list.- Parameters:
n
- the index to get- Returns:
- the n'th entry from the beginning.
-
get
Returns the element for the given hash key.- Parameters:
key
- the key to search for- Returns:
- the value of a keyed entry. Non-keyed entries may be returned by requesting an iterator.
- See Also:
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<VALUE extends CursorValue<String>>
-
iterator
Returns an iterator that will go over all elements of the list in the defined order.- Specified by:
iterator
in interfaceCollection<VALUE extends CursorValue<String>>
- Specified by:
iterator
in interfaceIterable<VALUE extends CursorValue<String>>
- Returns:
- an interator over the entire list.
- See Also:
-
iterator
Returns an iterator, which starts from the specified entry index, and goes over the remaining elements in the list.- Parameters:
n
- the index to start the iterator- Returns:
- an iterator starting with the n'th entry.
- See Also:
-
cursor
Return the iterator that represents the current position in the header. This provides a connection between editing headers through Header add/append/update methods, and via Cursors, which can be used side-by-side while maintaining desired card ordering. For the reverse direction ( translating iterator position to current position in the header), we can just use findCard().- Returns:
- the iterator representing the current position in the header.
- See Also:
-
iterator
Returns an iterator, which starts from the specified keyed entry, and goes over the remaining elements in the list.- Parameters:
key
- the key to use as a start point- Returns:
- an iterator over the list starting with the entry with a given key.
- See Also:
-
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
-
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
-