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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends VALUE> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleancontainsKey(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.booleanisEmpty()HashedList<VALUE>.nom.tam.util.HashedList.HashedListIteratoriterator()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.HashedListIteratorReturns an iterator, which starts from the specified keyed entry, and goes over the remaining elements in the list.booleanremove(int index) Remove an object from the list giving the object index..booleanbooleanremoveAll(Collection<?> c) booleanRemove a keyed object from the list.booleanreplaceKey(String oldKey, String newKey) Replace the key of a given element.booleanretainAll(Collection<?> c) intsize()voidsort(Comparator<String> comp) Sort the keys into some desired order.Object[]toArray()<T> T[]toArray(T[] o) toString()voidSimilar 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, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
HashedList
public HashedList()
-
-
Method Details
-
add
- Specified by:
addin 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:
addAllin interfaceCollection<VALUE extends CursorValue<String>>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<VALUE extends CursorValue<String>>
-
contains
- Specified by:
containsin interfaceCollection<VALUE extends CursorValue<String>>
-
containsAll
- Specified by:
containsAllin interfaceCollection<VALUE extends CursorValue<String>>
-
containsKey
Checks if the list contains an entry for the given keyword.- Parameters:
key- the key to search- Returns:
trueif 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:
isEmptyin interfaceCollection<VALUE extends CursorValue<String>>
-
iterator
Returns an iterator that will go over all elements of the list in the defined order.- Specified by:
iteratorin interfaceCollection<VALUE extends CursorValue<String>>- Specified by:
iteratorin 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:
removein interfaceCollection<VALUE extends CursorValue<String>>
-
removeAll
- Specified by:
removeAllin 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:
trueif 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:
retainAllin interfaceCollection<VALUE extends CursorValue<String>>
-
size
public int size()- Specified by:
sizein 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:
toArrayin interfaceCollection<VALUE extends CursorValue<String>>
-
toArray
public <T> T[] toArray(T[] o) - Specified by:
toArrayin interfaceCollection<VALUE extends CursorValue<String>>
-
toString
-