|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractCollection<E>
AbstractList<E>
UnmodifiableArrayList<E>
E - The type of elements in the list.public class UnmodifiableArrayList<E>
An unmodifiable view of an array. Invoking
is equivalent toUnmodifiableArrayList.wrap(array);
But this class uses one less level of indirection.Collections.unmodifiableList(Arrays.asList(array));
| utility/geotk-utility (download) | View source code for this class |
| Field Summary |
|---|
| Fields inherited from class AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
protected |
UnmodifiableArrayList(E... array)
Creates a new instance of an array list. |
| Method Summary | ||
|---|---|---|
int |
arraySize()
Returns the size of the array backing this list. |
|
boolean |
contains(Object object)
Returns true if this collection contains the specified element. |
|
boolean |
equals(Object object)
Compares this list with the given object for equality. |
|
E |
get(int index)
Returns the element at the specified index. |
|
Class<E> |
getElementType()
Returns the element type of the wrapped array. |
|
int |
indexOf(Object object)
Returns the index in this list of the first occurrence of the specified element, or -1 if the list does not contain this element. |
|
int |
lastIndexOf(Object object)
Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element. |
|
int |
size()
Returns the list size. |
|
UnmodifiableArrayList<E> |
subList(int lower,
int upper)
Returns a view of the portion of this list between the specified lower, inclusive, and upper, exclusive. |
|
static
|
wrap(E... array)
Creates a new instance of an array list. |
|
static
|
wrap(E[] array,
int lower,
int upper)
Creates a new instance of an array list over a subregion of the given array. |
|
| Methods inherited from class AbstractList |
|---|
add, add, addAll, clear, hashCode, iterator, listIterator, listIterator, remove, removeRange, set |
| Methods inherited from class AbstractCollection |
|---|
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Collection |
|---|
add, addAll, clear, containsAll, hashCode, isEmpty, iterator, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface List |
|---|
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
protected UnmodifiableArrayList(E... array)
This constructor is for subclassing only. Users should invoke the wrap(E...) static
factory method, which provides more convenient handling of parameterized types.
array - The array to wrap.| Method Detail |
|---|
public static <E> UnmodifiableArrayList<E> wrap(E... array)
E - The type of elements in the list.array - The array to wrap, or null if none.
null if the given
array was null.
public static <E> UnmodifiableArrayList<E> wrap(E[] array,
int lower,
int upper)
throws IndexOutOfBoundsException
E - The type of elements in the list.array - The array to wrap.lower - low endpoint (inclusive) of the sublist.upper - high endpoint (exclusive) of the sublist.
IndexOutOfBoundsException - If the lower or upper value are out of bounds.public Class<E> getElementType()
Class.getComponentType().
getElementType in interface CheckedCollection<E>getElementType in interface CheckedContainer<E>public int size()
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public final int arraySize()
size() except if this instance
is a sublist, in which case the value returned by this method
is greater than size().
This method is sometime used as a hint for choosing a UnmodifiableArrayList
instance to keep, given a choice. Note that a greater value is not necessarily more
memory consuming, since the backing array may be shared by many sublists.
public E get(int index)
get in interface List<E>get in class AbstractList<E>public int indexOf(Object object)
indexOf in interface List<E>indexOf in class AbstractList<E>object - The element to search for.
-1.public int lastIndexOf(Object object)
lastIndexOf in interface List<E>lastIndexOf in class AbstractList<E>object - The element to search for.
-1.public boolean contains(Object object)
true if this collection contains the specified element.
contains in interface Collection<E>contains in interface List<E>contains in class AbstractCollection<E>object - The element to check for existence.
true if this collection contains the given element.
public UnmodifiableArrayList<E> subList(int lower,
int upper)
throws IndexOutOfBoundsException
lower, inclusive, and upper, exclusive.
subList in interface List<E>subList in class AbstractList<E>lower - low endpoint (inclusive) of the sublist.upper - high endpoint (exclusive) of the sublist.
IndexOutOfBoundsException - If the lower or upper value are out of bounds.public boolean equals(Object object)
equals in interface Collection<E>equals in interface List<E>equals in class AbstractList<E>object - The object to compare with this list.
true if the given object is equal to this list.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||