ListValuedMap interface to simplify
the creation of subclass implementations.
Subclasses specify a Map implementation to use as the internal storage and the List implementation to use as values.
| Modifier and Type | Class and Description |
|---|---|
| private class | AbstractListValuedMap.ValuesListIterator
Values ListIterator |
| private class | AbstractListValuedMap.WrappedList
Wrapped list to handle add and remove on the list returned by get(object) |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | AbstractListValuedMap(final Map<K, ? extends List<V>>
the map to wrap, must not be null map)A constructor that wraps, not copies |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract List | Returns: a new listImplements abstract org. |
| public List | get(final K
the key to retrieve key)Overrides org. Implements org. |
| protected Map | getMap()
Overrides org. |
| public List | Returns: theList of values removed, will return an empty,
unmodifiable list for no mapping found.the key to remove values from key)Overrides org. Implements org. |
| pack-priv List |
| AbstractListValuedMap | back to summary |
|---|---|
| protected AbstractListValuedMap() Constructor needed for subclass serialisation. | |
| AbstractListValuedMap | back to summary |
|---|---|
| protected AbstractListValuedMap(final Map<K, ? extends List<V>> map) A constructor that wraps, not copies
| |
| createCollection | back to summary |
|---|---|
| protected abstract List Implements abstract org. Creates a new value collection using the provided factory. | |
| get | back to summary |
|---|---|
| public List Overrides org. Implements org. Gets the list of values associated with the specified key. This would return an empty list in case the mapping is not present | |
| getMap | back to summary |
|---|---|
| protected Map Overrides org. Doc from org. Gets the map being wrapped.
| |
| remove | back to summary |
|---|---|
| public List Overrides org. Implements org. Removes all values associated with the specified key.
A subsequent | |
| wrappedCollection | back to summary |
|---|---|
| pack-priv List Overrides org.
| |
| Modifier and Type | Field and Description |
|---|---|
| private ListIterator | |
| private final K | |
| private List |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(final V
the element to insert value)Implements java. |
| public boolean | hasNext()
Implements java. true if this list iterator has more elements when
traversing the list in the forward direction.
|
| public boolean | hasPrevious()
Implements java. true if this list iterator has more elements when
traversing the list in the reverse direction.
|
| public V | next()
Implements java. |
| public int | nextIndex()
Implements java. next.
|
| public V | previous()
Implements java. |
| public int | previousIndex()
Implements java. previous.
|
| public void | remove()
Implements java. next or previous (optional operation).
|
| public void | set(final V
the element with which to replace the last element returned by
value)next or previousImplements java. next or
previous with the specified element (optional operation).
|
| iterator | back to summary |
|---|---|
| private ListIterator<V> iterator | |
| key | back to summary |
|---|---|
| private final K key | |
| values | back to summary |
|---|---|
| private List<V> values | |
| ValuesListIterator | back to summary |
|---|---|
| public ValuesListIterator(final K key) | |
| ValuesListIterator | back to summary |
|---|---|
| public ValuesListIterator(final K key, final int index) | |
| add | back to summary |
|---|---|
| public void add(final V value) Implements java. Doc from java. Inserts the specified element into the list (optional operation).
The element is inserted immediately before the element that
would be returned by
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| hasPrevious | back to summary |
|---|---|
| public boolean hasPrevious() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public V next() Implements java. Doc from java. Returns the next element in the list and advances the cursor position.
This method may be called repeatedly to iterate through the list,
or intermixed with calls to
| |
| nextIndex | back to summary |
|---|---|
| public int nextIndex() Implements java. Doc from java. Returns the index of the element that would be returned by a
subsequent call to
| |
| previous | back to summary |
|---|---|
| public V previous() Implements java. Doc from java. Returns the previous element in the list and moves the cursor
position backwards. This method may be called repeatedly to
iterate through the list backwards, or intermixed with calls to
| |
| previousIndex | back to summary |
|---|---|
| public int previousIndex() Implements java. Doc from java. Returns the index of the element that would be returned by a
subsequent call to
| |
| remove | back to summary |
|---|---|
| public void remove() Implements java. Doc from java. Removes from the list the last element that was returned by
| |
| set | back to summary |
|---|---|
| public void set(final V value) Implements java. Doc from java. Replaces the last element returned by
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(final int
index at which the specified element is to be inserted index, final V element to be inserted value)Implements java. |
| public boolean | addAll(final int
index at which to insert the first element from the
specified collection index, final Collection<? extends V> collection containing elements to be added to this list c)Implements java. |
| public boolean | equals(final Object
the object to be compared for equality with this list other)Overrides java. Implements java. |
| public V | get(final int
index of the element to return index)Implements java. |
| protected List | |
| public int | hashCode()
Overrides java. Implements java. |
| public int | indexOf(final Object
element to search for o)Implements java. |
| public int | lastIndexOf(final Object
element to search for o)Implements java. |
| public ListIterator | listIterator()
Implements java. |
| public ListIterator | listIterator(final int
index of the first element to be returned from the
list iterator (by a call to index)next)Implements java. |
| public V | remove(final int
the index of the element to be removed index)Implements java. |
| public V | set(final int
index of the element to replace index, final V element to be stored at the specified position value)Implements java. |
| public List | subList(final int
low endpoint (inclusive) of the subList fromIndex, final int high endpoint (exclusive) of the subList toIndex)Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| WrappedList | back to summary |
|---|---|
| public WrappedList(final K key) | |
| add | back to summary |
|---|---|
| public void add(final int index, final V value) Implements java. Doc from java. Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final int index, final Collection<? extends V> c) Implements java. Doc from java. Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object other) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| get | back to summary |
|---|---|
| public V get(final int index) Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| getMapping | back to summary |
|---|---|
| protected List Overrides org.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two lists,
list1 and list2, as required by the general
contract of Object#hashCode.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(final Object o) Implements java. Doc from java. Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index | |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(final Object o) Implements java. Doc from java. Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the highest index | |
| listIterator | back to summary |
|---|---|
| public ListIterator Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper sequence).
| |
| listIterator | back to summary |
|---|---|
| public ListIterator Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
The specified index indicates the first element that would be
returned by an initial call to
| |
| remove | back to summary |
|---|---|
| public V remove(final int index) Implements java. Doc from java. Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
| |
| set | back to summary |
|---|---|
| public V set(final int index, final V value) Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| subList | back to summary |
|---|---|
| public List Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) | |