org.scijava.util
Class ObjectArray<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<BaseType>
org.scijava.util.AbstractPrimitiveArray<E[],E>
org.scijava.util.ObjectArray<E>
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>, PrimitiveArray<E[],E>, Sizable
public class ObjectArray<E>
- extends AbstractPrimitiveArray<E[],E>
An extensible, generic array of Object elements. Note that this class
is a PrimitiveArray but of course Objects are not primitives.
However, this class still facilitates improved conversion of Object array
types to collections, and thus remains useful (if not completely accurately
congruent with its type hierarchy).
This class still provides a convenient way to work around
Arrays.asList(Object...) creating a list with a single element. It
also contains improved performance implementations of many Collection
methods.
- Author:
- Mark Hiner, Johannes Schindelin, Curtis Rueden
|
Constructor Summary |
ObjectArray(Class<E> arrayType)
Constructs an extensible array of objects, backed by a fixed-size array. |
ObjectArray(Class<E> arrayType,
int size)
Constructs an extensible array of objects, backed by a fixed-size array. |
ObjectArray(E[] array)
Constructs an extensible array of objects, backed by the given fixed-size
array. |
| Methods inherited from class org.scijava.util.AbstractPrimitiveArray |
capacity, checkBounds, clear, copyArray, delete, ensureCapacity, getMaximumGrowth, insert, remove, setMaximumGrowth, setSize, size |
| Methods inherited from interface java.util.List |
add, addAll, equals, hashCode, isEmpty, iterator, listIterator, listIterator, retainAll, subList, toArray, toArray |
ObjectArray
public ObjectArray(Class<E> arrayType)
- Constructs an extensible array of objects, backed by a fixed-size array.
ObjectArray
public ObjectArray(Class<E> arrayType,
int size)
- Constructs an extensible array of objects, backed by a fixed-size array.
- Parameters:
size - the initial size
ObjectArray
public ObjectArray(E[] array)
- Constructs an extensible array of objects, backed by the given fixed-size
array.
- Parameters:
array - the array to wrap
addValue
public void addValue(E value)
removeValue
public boolean removeValue(E value)
getValue
public E getValue(int index)
setValue
public E setValue(int index,
E value)
addValue
public void addValue(int index,
E value)
getArray
public E[] getArray()
- Description copied from interface:
PrimitiveArray
- Gets the fixed-size array backing this instance.
- Returns:
- the backing array
setArray
public void setArray(E[] array)
- Description copied from interface:
PrimitiveArray
- Sets the fixed-size array backing this instance.
- Parameters:
array - the new backing array
get
public E get(int index)
- Specified by:
get in interface List<E>- Specified by:
get in class AbstractList<E>
set
public E set(int index,
E element)
- Specified by:
set in interface List<E>- Specified by:
set in class AbstractPrimitiveArray<E[],E>
add
public void add(int index,
E element)
- Specified by:
add in interface List<E>- Specified by:
add in class AbstractPrimitiveArray<E[],E>
indexOf
public int indexOf(Object o)
- Specified by:
indexOf in interface List<E>- Overrides:
indexOf in class AbstractList<E>
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf in interface List<E>- Overrides:
lastIndexOf in class AbstractList<E>
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<E>- Specified by:
contains in interface List<E>- Overrides:
contains in class AbstractCollection<E>
remove
public boolean remove(Object o)
- Specified by:
remove in interface Collection<E>- Specified by:
remove in interface List<E>- Overrides:
remove in class AbstractCollection<E>
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll in interface Collection<E>- Specified by:
containsAll in interface List<E>- Overrides:
containsAll in class AbstractCollection<E>
addAll
public boolean addAll(int index,
Collection<? extends E> c)
- Specified by:
addAll in interface List<E>- Overrides:
addAll in class AbstractList<E>
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll in interface Collection<E>- Specified by:
removeAll in interface List<E>- Overrides:
removeAll in class AbstractCollection<E>
defaultValue
public E defaultValue()
Copyright © 2009–2014 SciJava. All rights reserved.