@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.
| 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) |
E |
get(int index) |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
void |
readExternal(ObjectInput in)
See
ImmutableListCopy.writeExternal(java.io.ObjectOutput) for serialization format |
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) |
void |
writeExternal(ObjectOutput out)
Format: - entry array size (int) - elements (Object)
|
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 class AbstractCollection<E>public final boolean isEmpty()
isEmpty in class AbstractCollection<E>public final boolean contains(Object o)
contains in class AbstractCollection<E>public final Iterator<E> iterator()
iterator in class AbstractList<E>public final Object[] toArray()
toArray in class AbstractCollection<E>public final <T> T[] toArray(T[] a)
toArray in class AbstractCollection<E>public final boolean add(E o)
add in class AbstractList<E>public final boolean remove(Object o)
remove in class AbstractCollection<E>public final boolean addAll(Collection<? extends E> c)
addAll in class AbstractCollection<E>public final boolean addAll(int index,
Collection<? extends E> c)
addAll in class AbstractList<E>public final boolean removeAll(Collection<?> c)
removeAll in class AbstractCollection<E>public final boolean retainAll(Collection<?> c)
retainAll in class AbstractCollection<E>public final E get(int index)
get in class AbstractList<E>public final int indexOf(Object o)
indexOf in class AbstractList<E>public final int lastIndexOf(Object o)
lastIndexOf in class AbstractList<E>public final ListIterator<E> listIterator()
listIterator in class AbstractList<E>public final ListIterator<E> listIterator(int index)
listIterator in class AbstractList<E>public final List<E> subList(int fromIndex, int toIndex)
subList in class AbstractList<E>public void writeExternal(ObjectOutput out)
out - stream to write toIOExceptionpublic void readExternal(ObjectInput in)
ImmutableListCopy.writeExternal(java.io.ObjectOutput) for serialization formatin - streamIOExceptionClassNotFoundExceptionCopyright © 2015 JBoss, a division of Red Hat. All rights reserved.