E
- the type of element in the listK
- the type of optional associative keyspublic interface AssociativeList<E,K> extends List<E>
Modifier and Type | Method and Description |
---|---|
int |
add(E element,
K key)
Adds an element with an associative key.
|
int |
add(int index,
E element,
K key)
Adds an element with an associative key.
|
Map<K,Integer> |
addAll(AssociativeList<? extends E,? extends K> mappedElements)
Adds a collection of mapped entries from another
AssociativeList . |
Map<K,Integer> |
addAll(int index,
AssociativeList<? extends E,? extends K> mappedElements)
Adds a collection of mapped entries from another
AssociativeList . |
Map<K,Integer> |
addAll(int index,
Map<? extends K,? extends E> mappedElements)
Adds a collection of mapped entries from a map.
|
Map<K,Integer> |
addAll(Map<? extends K,? extends E> mappedElements)
Adds a collection of mapped entries from a map.
|
Map<K,E> |
asMap()
Returns a view of the associative mappings in this list.
|
K |
clearKey(int index)
Clears an associative key from a given list index.
|
boolean |
containsKey(K key)
Determines if the specified key is associated with an element in the list.
|
int |
createKey(K key,
int index)
Adds a key for an existing list element.
|
int |
forgetKey(K key)
Removes an associative key but leaves the list and associated element in tact.
|
E |
getByKey(K key)
Retrieves a list element via its associative key.
|
int |
getKeyIndex(K key)
Finds the list index associated with a given key.
|
boolean |
hasKey(int index)
Determines if the specified list index is associated with a key.
|
ListIterator<Map.Entry<K,E>> |
keyedEntryIterator()
Returns an iterator over the associative mappings in the list in proper order.
|
ListIterator<K> |
keyIterator()
Returns an iterator over the associative keys in the list in proper order.
|
int |
nextKeyedIndex(int start)
Returns the next index in the list, that is greater than or equal to the specified index, that
has an associated key.
|
Map.Entry<Integer,E> |
removeByKey(K key)
Removes an element via its associative key.
|
AssociativeList<E,K> |
subList(int fromIndex,
int toIndex)
Returns a view of a subset of this list.
|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
int add(E element, K key)
element
- the new element to add to the end of the listkey
- an associative key for the new elementint add(int index, E element, K key)
index
- the index at which the new element is insertedelement
- the new element to add to the end of the listkey
- an associative key for the new elementIndexOutOfBoundsException
- if the specified index is negative or is greater than the
size of this listMap<K,Integer> addAll(Map<? extends K,? extends E> mappedElements)
mappedElements
- the values and associated keys to add to the listMap<K,Integer> addAll(int index, Map<? extends K,? extends E> mappedElements)
index
- the index at which the new elements are insertedmappedElements
- the values and associated keys to add to the listIndexOutOfBoundsException
- if the specified index is negative or is greater than the
size of this listMap<K,Integer> addAll(AssociativeList<? extends E,? extends K> mappedElements)
AssociativeList
. They are added to
the end of the list. Any key that was already associated with an element in the list will
instead be associated with its corresponding value in the specified map. The returned map, if
not empty, contains any such overwritten keys along with their previously associated list
index.mappedElements
- the values and associated keys to add to the listMap<K,Integer> addAll(int index, AssociativeList<? extends E,? extends K> mappedElements)
AssociativeList
. Any key that was
already associated with an element in the list will instead be associated with its
corresponding value in the specified map. The returned map, if not empty, contains any such
overwritten keys along with their previously associated list index.index
- the index at which the new elements are insertedmappedElements
- the values and associated keys to add to the listIndexOutOfBoundsException
- if the specified index is negative or is greater than the
size of this listint createKey(K key, int index)
key
- the associative keyindex
- the list index to associate with the keyIndexOutOfBoundsException
- if the specified index is negative or is greater than the
largest valid index in this listE getByKey(K key)
key
- the associative keynull
if no such associative key existsint getKeyIndex(K key)
key
- the associative keyMap.Entry<Integer,E> removeByKey(K key)
key
- the associative keynull
if no such associative key existsint forgetKey(K key)
key
- the associative keyK clearKey(int index)
index
- the indexnull
if it was not
previously mappedIndexOutOfBoundsException
- if the specified index is negative or is greater than the
largest valid index in this listboolean hasKey(int index)
index
- index into the listIndexOutOfBoundsException
- if the specified index is negative or is greater than the
largest valid index in this listboolean containsKey(K key)
key
- the associative keyListIterator<K> keyIterator()
ListIterator<Map.Entry<K,E>> keyedEntryIterator()
int nextKeyedIndex(int start)
for (int i = list.nextKeyedIndex(0); i >= 0; i = list.nextKeyedIndex(i + 1)) { // i is an index associated with a key }
start
- the starting index for searching for an index with a keyIndexOutOfBoundsException
- if the specified index is negative or is greater than the
size of the listMap<K,E> asMap()
UnsupportedOperationException
.