Modifications made to this decorator modify the index as well as the
decorated Collection. However, modifications to the underlying
Collection will not update the index and it will get out of sync.
If modification of the decorated Collection is unavoidable, then a
call to reindex() will update the index to the current contents of
the Collection.
| Modifier and Type | Field and Description |
|---|---|
| private final MultiMap | index
The map of indexes to collected objects. |
| private final Transformer | keyTransformer
The |
| private static final long | serialVersionUID
Hides org. |
| private final boolean | uniqueIndex
The uniqueness constraint for the index. |
| Access | Constructor and Description |
|---|---|
| public | IndexedCollection(final Collection<C>
decorated coll, final Transformer<C, K> CollectionTransformer for generating index keysmap to use as index map, final boolean if the index shall enforce uniqueness of index keys uniqueIndex)
Deprecated
as a consequence of
Create a MultiMap being deprecated.
IndexedCollection.
|
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(final C
element whose presence in this collection is to be ensured object)Overrides org. Implements java. |
| public boolean | addAll(final Collection<? extends C>
collection containing elements to be added to this collection coll)Overrides org. Implements java. |
| private void | |
| public void | clear()
Overrides org. Implements java. |
| public boolean | contains(final Object
element whose presence in this collection is to be tested object)Overrides org. Implements java. true if this collection contains the specified element.
|
| public boolean | containsAll(final Collection<?>
collection to be checked for containment in this collection coll)Overrides org. Implements java. true if this collection contains all of the elements
in the specified collection.
|
| public C | |
| public static < the index object type. K, the collection type. C> IndexedCollection | Returns: the createdIndexedCollection.the decorated coll, final Transformer<C, K> Collection.the keyTransformer)Transformer for generating index keys.Create an |
| public void | |
| public boolean | remove(final Object
element to be removed from this collection, if present object)Overrides org. Implements java. |
| public boolean | removeAll(final Collection<?>
collection containing elements to be removed from this collection coll)Overrides org. Implements java. |
| private void | |
| public boolean | removeIf(final Predicate<? super C>
a predicate which returns filter)true for elements to be
removedOverrides org. Overrides default java. |
| public boolean | retainAll(final Collection<?>
collection containing elements to be retained in this collection coll)Overrides org. Implements java. |
| public static < the index object type. K, the collection type. C> IndexedCollection | Returns: the createdIndexedCollection.the decorated coll, final Transformer<C, K> Collection.the keyTransformer)Transformer for generating index keys.Create an |
| public Collection | Returns: a collection of elements found, or null ifcontains(key) == falsekey to look up key)Get all elements associated with the given key. |
| index | back to summary |
|---|---|
| private final MultiMap<K, C> index
Deprecated as a consequence of The map of indexes to collected objects. | |
| keyTransformer | back to summary |
|---|---|
| private final Transformer<C, K> keyTransformer The | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| uniqueIndex | back to summary |
|---|---|
| private final boolean uniqueIndex The uniqueness constraint for the index. | |
| IndexedCollection | back to summary |
|---|---|
| public IndexedCollection(final Collection<C> coll, final Transformer<C, K> keyTransformer, final MultiMap<K, C> map, final boolean uniqueIndex)
Deprecated as a consequence of Create a
| |
| add | back to summary |
|---|---|
| public boolean add(final C object) Overrides org. Implements java. Doc from java. Ensures that this collection contains the specified element (optional
operation). Returns
Collections that support this operation may place limitations on what
elements may be added to this collection. In particular, some
collections will refuse to add
If a collection refuses to add a particular element for any reason
other than that it already contains the element, it must throw
an exception (rather than returning
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final Collection<? extends C> coll) Overrides org. Implements java. Doc from java. Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) If the specified collection has a defined encounter order, processing of its elements generally occurs in that order.
| |
| addToIndex | back to summary |
|---|---|
| private void addToIndex(final C object) Provides checking for adding the index.
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides org. Implements java. Doc from java. Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(final Object object) Overrides org. Implements java. Doc from java. Returns Note uses the index for fast lookup
| |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(final Collection<?> coll) Overrides org. Implements java. Doc from java. Returns Note uses the index for fast lookup
| |
| get | back to summary |
|---|---|
| public C get(final K key) Get the element associated with the given key.
In case of a non-unique index, this method will return the first
value associated with the given key. To retrieve all elements associated
with a key, use
| |
| nonUniqueIndexedCollection | back to summary |
|---|---|
| public static <K, C> IndexedCollection Create an
| |
| reindex | back to summary |
|---|---|
| public void reindex() Clears the index and re-indexes the entire decorated | |
| remove | back to summary |
|---|---|
| public boolean remove(final Object object) Overrides org. Implements java. Doc from java. Removes a single instance of the specified element from this
collection, if it is present (optional operation). More formally,
removes an element
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(final Collection<?> coll) Overrides org. Implements java. Doc from java. Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
| |
| removeFromIndex | back to summary |
|---|---|
| private void removeFromIndex(final C object) Removes an object from the index.
| |
| removeIf | back to summary |
|---|---|
| public boolean removeIf(final Predicate<? super C> filter) Overrides org. Overrides default java. Doc from java. Removes all of the elements of this collection that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller. | |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(final Collection<?> coll) Overrides org. Implements java. Doc from java. Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
| |
| uniqueIndexedCollection | back to summary |
|---|---|
| public static <K, C> IndexedCollection Create an
If an element is added, which maps to an existing key, an
| |
| values | back to summary |
|---|---|
| public Collection Get all elements associated with the given key.
| |