T - the list element typepublic class ImmutableList<T> extends ImmutableCollection<T> implements List<T>, RandomAccess
List.| Constructor and Description |
|---|
ImmutableList(List<T> list)
Construct an
ImmutableList from another List (helps with deserializing). |
ImmutableList(T[] array)
Construct an
ImmutableList with the given array (using the entire array). |
ImmutableList(T[] array,
int length)
Construct an
ImmutableList with the given array and length. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element)
Modifying operation - not allowed.
|
boolean |
addAll(int index,
Collection<? extends T> c)
Modifying operation - not allowed.
|
static <TT> ImmutableList<TT> |
emptyList()
Get an empty
ImmutableList. |
boolean |
equals(Object other)
Compares the specified object with this list for equality.
|
int |
hashCode()
Returns the hash code value for this list.
|
int |
indexOf(Object o)
Find the index in the list of the first item equal to the given object (either both
null, or equal
according to Object.equals(java.lang.Object)). |
int |
lastIndexOf(Object o)
Find the index in the list of the last item equal to the given object (either both
null, or equal
according to Object.equals(java.lang.Object)). |
ListIterator<T> |
listIterator()
Get a
ListIterator over this list. |
ListIterator<T> |
listIterator(int index)
Get a
ListIterator over this list, initialised to the given index. |
static <TT> ImmutableList<TT> |
listOf(TT[] array)
Get an
ImmutableList using the supplied array. |
static <TT> ImmutableList<TT> |
listOf(TT[] array,
int length)
Get an
ImmutableList using the supplied array. |
T |
remove(int index)
Modifying operation - not allowed.
|
T |
set(int index,
T element)
Modifying operation - not allowed.
|
ImmutableList<T> |
subList(int fromIndex,
int toIndex)
Get a sub-list of this list.
|
contains, contains, get, iterator, toArray, toArrayadd, addAll, containsAll, remove, removeAll, retainAll, toStringclear, isEmpty, sizeclone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, contains, containsAll, get, isEmpty, iterator, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic ImmutableList(T[] array, int length)
ImmutableList with the given array and length.
array - the arraylength - the length (the number of array items to be considered part of the list)IndexOutOfBoundsException - if the length is less than 0 or greater than the array lengthpublic ImmutableList(T[] array)
ImmutableList with the given array (using the entire array).
array - the arraypublic int indexOf(Object o)
null, or equal
according to Object.equals(java.lang.Object)).public int lastIndexOf(Object o)
null, or equal
according to Object.equals(java.lang.Object)).lastIndexOf in interface List<T>o - the object to be locatedpublic ListIterator<T> listIterator()
ListIterator over this list.listIterator in interface List<T>ListIteratorpublic ListIterator<T> listIterator(int index)
ListIterator over this list, initialised to the given index.listIterator in interface List<T>index - the starting indexListIteratorpublic ImmutableList<T> subList(int fromIndex, int toIndex)
subList in interface List<T>fromIndex - the starting index of the sub-listtoIndex - the ending index of the sub-listIndexOutOfBoundsException - if the index range is not validpublic void add(int index,
T element)
add in interface List<T>UnsupportedOperationException - (in all cases)public T set(int index, T element)
set in interface List<T>UnsupportedOperationException - (in all cases)public boolean addAll(int index,
Collection<? extends T> c)
addAll in interface List<T>UnsupportedOperationException - (in all cases)public T remove(int index)
remove in interface List<T>UnsupportedOperationException - (in all cases)public boolean equals(Object other)
true if and only if the specified
object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists
are equal (that is, both are null or they compare as equal using Object.equals(java.lang.Object)). This definition ensures
that the Object.equals(java.lang.Object) method works properly across different implementations of the List
interface.public int hashCode()
This implementation uses exactly the code that is used to define the list hash function in the documentation
for the List.hashCode() method.
public static <TT> ImmutableList<TT> emptyList()
ImmutableList. This avoids a memory allocation if the list is empty.TT - the element typepublic static <TT> ImmutableList<TT> listOf(TT[] array)
ImmutableList using the supplied array. If the array length is zero, the empty list is returned.
TT - the element typearray - the arraypublic static <TT> ImmutableList<TT> listOf(TT[] array, int length)
ImmutableList using the supplied array. If the array length is zero, the empty list is returned.
TT - the element typearray - the arraylength - the length (the number of array items to be considered part of the list)Copyright © 2023. All rights reserved.