T - the collection element typepublic class ImmutableCollection<T> extends ImmutableCollectionBase<T,T> implements Collection<T>
Collection.| Constructor and Description |
|---|
ImmutableCollection(Collection<T> collection)
Construct an
ImmutableCollection from another Collection (helps with deserializing). |
ImmutableCollection(T[] array)
Construct an
ImmutableCollection with the given array (using the entire array). |
ImmutableCollection(T[] array,
int length)
Construct an
ImmutableCollection with the given array and length. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Object o)
Test whether the collection contains an object equal to the specified value (which may be
null). |
static <TT> boolean |
contains(TT[] array,
int length,
Object o)
Test whether a given array contains an object equal to the specified value (which may be
null). |
T |
get(int index)
Get the element at the specified index.
|
Iterator<T> |
iterator()
Return an
Iterator over the collection. |
Object[] |
toArray()
Create a copy of the underlying array.
|
<TT> TT[] |
toArray(TT[] a)
Return a copy of the underlying array, either in the supplied array (if it fits) or in a new array of the
specified type.
|
add, addAll, containsAll, remove, removeAll, retainAll, toStringclear, isEmpty, sizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, streampublic ImmutableCollection(T[] array, int length)
ImmutableCollection with the given array and length.array - the arraylength - the length (the number of array items to be considered part of the collection)IndexOutOfBoundsException - if the length is less than 0 or greater than the array lengthpublic ImmutableCollection(T[] array)
ImmutableCollection with the given array (using the entire array).array - the arraypublic ImmutableCollection(Collection<T> collection)
ImmutableCollection from another Collection (helps with deserializing).collection - the other Collectionpublic boolean contains(Object o)
null).contains in interface Collection<T>o - the objecttrue if the collection contains the objectpublic Object[] toArray()
toArray in interface Collection<T>public <TT> TT[] toArray(TT[] a)
toArray in interface Collection<T>TT - the type of the destination array itemsa - the destination arrayArrayStoreException - if the values in the collection can't be stored in the destination arraypublic T get(int index)
Collection interface, but it
allows iteration over the members of a collection without needing to instantiate an Iterator.
The function does not check the index because the indexing operation on the array will do that anyway.index - the indexIndexOutOfBoundsException - if the index is less than 0 or greater than the length of the listpublic static <TT> boolean contains(TT[] array,
int length,
Object o)
null).TT - the type of the array itemsarray - the arraylength - the number of elements in the array to be examinedo - the objecttrue if the collection contains the objectCopyright © 2023. All rights reserved.