To create a new instance that wraps a collection with the MutableSet interface, use the wrapSet(Iterable)
factory method. To create a new instance that wraps a collection with the MutableList interface, use the
wrapList(Iterable) factory method. To wrap a collection with the MutableCollection interface alone, use
the adapt(Collection) factory method.
| Modifier and Type | Field and Description |
|---|---|
| private final Collection | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static <E> MutableCollection | |
| public MutableCollection | asSynchronized()
Implements org. Returns a synchronized wrapper backed by this collection. |
| public MutableCollection | asUnmodifiable()
Implements org. Returns an unmodifiable view of this collection. |
| public boolean | equals(Object o)
Overrides java. Implements java. Compares the specified object with this collection for equality. |
| protected Collection | |
| public int | hashCode()
Overrides java. Implements java. Returns the hash code value for this collection. |
| public MutableCollection | newEmpty()
Implements org.
Deprecated
use
FastList#newList() or UnifiedSet#newSet() instead
Creates a new empty mutable version of the same collection type. |
| public ImmutableCollection | toImmutable()
Implements org. Converts this |
| public CollectionAdapter | with(T... elements)
Implements org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. |
| public CollectionAdapter | with(T element)
Implements org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. |
| public CollectionAdapter | withAll(Iterable<? extends T> elements)
Implements org. This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. |
| public CollectionAdapter | without(T element)
Implements org. This method allows mutable and fixed size collections the ability to remove elements from their existing elements. |
| public CollectionAdapter | withoutAll(Iterable<? extends T> elements)
Implements org. This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. |
| public static <E> MutableList | |
| public static <E> MutableSet |
| delegate | back to summary |
|---|---|
| private final Collection<T> delegate | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| CollectionAdapter | back to summary |
|---|---|
| public CollectionAdapter(Collection<T> newDelegate) | |
| adapt | back to summary |
|---|---|
| public static <E> MutableCollection | |
| asSynchronized | back to summary |
|---|---|
| public MutableCollection Implements org. Doc from org. Returns a synchronized wrapper backed by this collection. This is the equivalent of using
MutableCollection synchedCollection = collection.asSynchronized();
...
synchedCollection.forEach(each -> ... );
synchedCollection.select(each -> ... );
synchedCollection.collect(each -> ... );
If you want to iterate using an imperative style, you must protect external iterators using
a synchronized block. This includes explicit iterators as well as JDK 5 style for loops.
| |
| asUnmodifiable | back to summary |
|---|---|
| public MutableCollection Implements org. Doc from org. Returns an unmodifiable view of this collection. This is the equivalent of using
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this collection for equality.
While the
The general contract for the
| |
| getDelegate | back to summary |
|---|---|
| protected Collection Implements abstract org.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this collection. While the
| |
| newEmpty | back to summary |
|---|---|
| public MutableCollection Implements org. Doc from org. Deprecated use Creates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.
| |
| toImmutable | back to summary |
|---|---|
| public ImmutableCollection Implements org. Doc from org. Converts this
| |
| with | back to summary |
|---|---|
| public CollectionAdapter Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.with("1");
list = list.with("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by with, and any
variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling add on itself.
| |
| with | back to summary |
|---|---|
| public CollectionAdapter Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.with("1");
list = list.with("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by with, and any
variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling add on itself.
| |
| withAll | back to summary |
|---|---|
| public CollectionAdapter Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling addAll on itself.
| |
| without | back to summary |
|---|---|
| public CollectionAdapter Implements org. Doc from org. This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.without("1");
list = list.without("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by without, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling remove on itself.
| |
| withoutAll | back to summary |
|---|---|
| public CollectionAdapter Implements org. Doc from org. This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll,
and any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling removeAll on itself.
| |
| wrapList | back to summary |
|---|---|
| public static <E> MutableList | |
| wrapSet | back to summary |
|---|---|
| public static <E> MutableSet | |