@Immutable public class ImmutableListCopy<E> extends AbstractList<E> implements Immutables.Immutable
return
Collections.unmodifiableList(new ArrayList( myInternalList ));
a it is far more efficient than making a defensive copy and then wrapping the defensive copy in a read-only wrapper.
Also used whenever a read-only reference List is needed.
Modifier and Type | Class and Description |
---|---|
static class |
ImmutableListCopy.Externalizer |
class |
ImmutableListCopy.ImmutableSubList<E> |
modCount
Constructor and Description |
---|
ImmutableListCopy()
Constructs a new ImmutableListCopy.
|
ImmutableListCopy(Collection<? extends E> c)
Only one copy constructor since the list is immutable.
|
ImmutableListCopy(Collection<? extends E> collection1,
Collection<? extends E> collection2)
Utility constructors to allow combining collections
|
ImmutableListCopy(E[] array)
Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o) |
boolean |
addAll(Collection<? extends E> c) |
boolean |
addAll(int index,
Collection<? extends E> c) |
boolean |
contains(Object o) |
boolean |
equals(Object o) |
E |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
List<E> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
add, clear, remove, removeRange, set
containsAll, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll, replaceAll, sort, spliterator
parallelStream, removeIf, stream
public ImmutableListCopy()
public ImmutableListCopy(Collection<? extends E> c)
c
- collection to copy frompublic ImmutableListCopy(E[] array)
array
- to referencepublic ImmutableListCopy(Collection<? extends E> collection1, Collection<? extends E> collection2)
collection1
- collection to copy fromcollection2
- collection to copy frompublic final int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractCollection<E>
public final boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface List<E>
isEmpty
in class AbstractCollection<E>
public final boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface List<E>
contains
in class AbstractCollection<E>
public final Object[] toArray()
toArray
in interface Collection<E>
toArray
in interface List<E>
toArray
in class AbstractCollection<E>
public final <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in interface List<E>
toArray
in class AbstractCollection<E>
public final boolean add(E o)
add
in interface Collection<E>
add
in interface List<E>
add
in class AbstractList<E>
public final boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface List<E>
remove
in class AbstractCollection<E>
public final boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class AbstractCollection<E>
public final boolean addAll(int index, Collection<? extends E> c)
public final boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class AbstractCollection<E>
public final boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
retainAll
in interface List<E>
retainAll
in class AbstractCollection<E>
public final E get(int index)
public final int indexOf(Object o)
public final int lastIndexOf(Object o)
lastIndexOf
in interface List<E>
lastIndexOf
in class AbstractList<E>
public final ListIterator<E> listIterator()
listIterator
in interface List<E>
listIterator
in class AbstractList<E>
public final ListIterator<E> listIterator(int index)
listIterator
in interface List<E>
listIterator
in class AbstractList<E>
public boolean equals(Object o)
equals
in interface Collection<E>
equals
in interface List<E>
equals
in class AbstractList<E>
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in interface List<E>
hashCode
in class AbstractList<E>
Copyright © 2021 JBoss by Red Hat. All rights reserved.