@Immutable public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable, 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.
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) |
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
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)
|
add, clear, equals, hashCode, remove, removeRange, set
containsAll, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll
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 void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
out
- stream to write toIOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
writeExternal(java.io.ObjectOutput)
for serialization formatreadExternal
in interface Externalizable
in
- streamIOException
ClassNotFoundException
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.