- Type Parameters:
E- the type of elements contained in the list. The immutable list is covariant on its element type.
- All Superinterfaces:
ImmutableCollection<E>, Iterable<E>
- All Known Subinterfaces:
PersistentList<E>
- All Known Implementing Classes:
ImmutableList.SubList
A generic immutable ordered collection of elements. Methods in this interface support only read-only access to the immutable list.
Modification operations are supported through the PersistentList interface.
Implementors of this interface take responsibility to be immutable. Once constructed they must contain the same elements in the same order.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classImmutableList.SubList<E extends @Nullable Object> -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableList<Character> from(CharSequence chars) Returns an immutable list containing all characters.static <T extends @Nullable Object>
ImmutableList<T> Returns an immutable list containing all elements of the specified collection.static <T extends @Nullable Object>
ImmutableList<T> Returns an immutable list containing all elements of the specified sequence.static <T extends @Nullable Object>
ImmutableList<T> from(T[] array) Returns an immutable list containing all elements of the specified array.get(int index) Returns the element at the specified index in the list.intReturns the index of the first occurrence of the specified element in the list, or-1if the specified element is not contained in the list.intlastIndexOf(E element) Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.Returns a list iterator over the elements in this list (in proper sequence).listIterator(int index) Returns a list iterator over the elements in this list (in proper sequence), starting at the specifiedindex.default ImmutableList<E> subList(int fromIndex, int toIndex) Returns a view of the portion of this list between the specifiedfromIndex(inclusive) andtoIndex(exclusive).Methods inherited from interface ImmutableCollection
contains, containsAll, isEmpty, iterator, parallelStream, size, streamMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
from
Returns an immutable list containing all elements of the specified collection.
If the specified collection is already an immutable list, returns it as is.
-
from
Returns an immutable list containing all elements of the specified array. -
from
Returns an immutable list containing all elements of the specified sequence. -
from
Returns an immutable list containing all characters. -
get
Returns the element at the specified index in the list.- Throws:
IndexOutOfBoundsException- ifindexis less than zero or greater than or equal tosizeof this list.
-
indexOf
Returns the index of the first occurrence of the specified element in the list, or
-1if the specified element is not contained in the list.For lists containing more than
Int.MAX_VALUEelements, a result of this function is unspecified. -
lastIndexOf
Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.
For lists containing more than
Int.MAX_VALUEelements, a result of this function is unspecified. -
listIterator
ListIterator<E> listIterator()Returns a list iterator over the elements in this list (in proper sequence). -
listIterator
Returns a list iterator over the elements in this list (in proper sequence), starting at the specifiedindex.- Throws:
IndexOutOfBoundsException- ifindexis less than zero or greater than or equal tosizeof this list.
-
subList
Returns a view of the portion of this list between the specified
fromIndex(inclusive) andtoIndex(exclusive).The returned list is backed by this list.
- Throws:
IndexOutOfBoundsException- iffromIndexis less than zero ortoIndexis greater than the size of this list.IllegalArgumentException- iffromIndexis greater thantoIndex.
-