Package com.globalmentor.collections
Class DecoratorIDedMappedList<K,E extends IDed<K>>
java.lang.Object
com.globalmentor.collections.CollectionDecorator<E>
com.globalmentor.collections.ListDecorator<E>
com.globalmentor.collections.DecoratorIDedMappedList<K,E>
- All Implemented Interfaces:
MappedList<K,
,E> Iterable<E>
,Collection<E>
,List<E>
public class DecoratorIDedMappedList<K,E extends IDed<K>>
extends ListDecorator<E>
implements MappedList<K,E>
A list that allows quick lookup of
IDed
objects. This list will give unpredictable results if multiple objects with the same ID are added to the
list.- Author:
- Garret Wilson
- Implementation Specification:
- This list does not support
null
values.
-
Field Summary
Fields inherited from class com.globalmentor.collections.ListDecorator
list
Fields inherited from class com.globalmentor.collections.CollectionDecorator
collection
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends E> c) boolean
addAll
(Collection<? extends E> c) void
clear()
boolean
containsKey
(Object key) Returnstrue
if this map contains a mapping for the specified key.Returns the value to which this map maps the specified key.getMap()
remove
(int index) boolean
boolean
removeAll
(Collection<?> c) Removes the value from the list mapped to the given key value.boolean
retainAll
(Collection<?> c) Methods inherited from class com.globalmentor.collections.ListDecorator
get, indexOf, lastIndexOf, listIterator, listIterator, replaceAll, sort, subList
Methods inherited from class com.globalmentor.collections.CollectionDecorator
contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, size, spliterator, stream, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
DecoratorIDedMappedList
Decorates the given list by mapping its values. Any values present in the map will be removed. Any values already present in the list will be mapped.- Parameters:
map
- The map which stores the ID to list item associations.list
- The list in which to store the list items.- Throws:
IllegalArgumentException
- if more than one item with the same ID exists in the list.
-
-
Method Details
-
getMap
- Returns:
- The map associating IDs with list items.
-
add
-
remove
-
addAll
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
set
-
add
-
remove
-
containsKey
Description copied from interface:MappedList
Returnstrue
if this map contains a mapping for the specified key. More formally, returnstrue
if and only if this map contains a mapping for a keyk
such that(key==null ? k==null : key.equals(k))
. (There can be at most one such mapping.)- Specified by:
containsKey
in interfaceMappedList<K,
E extends IDed<K>> - Parameters:
key
- key whose presence in this map is to be tested.- Returns:
true
if this map contains a mapping for the specified key.
-
get
Description copied from interface:MappedList
Returns the value to which this map maps the specified key. Returnsnull
if the map contains no mapping for this key. A return value ofnull
does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull
. ThecontainsKey
operation may be used to distinguish these two cases.More formally, if this map contains a mapping from a key
k
to a valuev
such that(key==null ? k==null : key.equals(k))
, then this method returnsv
; otherwise it returnsnull
. (There can be at most one such mapping.) -
removeKey
Description copied from interface:MappedList
Removes the value from the list mapped to the given key value.
-