- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<BaseType>
-
- org.scijava.collections.AbstractPrimitiveArray<E[],E>
-
- org.scijava.collections.ObjectArray<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,PrimitiveArray<E[],E>
public class ObjectArray<E> extends AbstractPrimitiveArray<E[],E>
An extensible, generic array ofObjectelements. Note that this class is aPrimitiveArraybut 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 manyCollectionmethods.- Author:
- Mark Hiner, Johannes Schindelin, Curtis Rueden
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description ObjectArray(E[] array)Constructs an extensible array of objects, backed by the given fixed-size array.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E element)booleanaddAll(int index, Collection<? extends E> c)voidaddValue(int index, E value)voidaddValue(E value)booleancontains(Object o)booleancontainsAll(Collection<?> c)EdefaultValue()Eget(int index)E[]getArray()Gets the fixed-size array backing this instance.EgetValue(int index)intindexOf(Object o)intlastIndexOf(Object o)booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanremoveValue(E value)Eset(int index, E element)voidsetArray(E[] array)Sets the fixed-size array backing this instance.EsetValue(int index, E value)-
Methods inherited from class org.scijava.collections.AbstractPrimitiveArray
capacity, checkBounds, clear, copyArray, delete, ensureCapacity, getMaximumGrowth, insert, remove, setMaximumGrowth, setSize, size
-
Methods inherited from class java.util.AbstractList
add, equals, hashCode, iterator, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, isEmpty, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
add, addAll, equals, hashCode, isEmpty, iterator, listIterator, listIterator, replaceAll, retainAll, sort, spliterator, subList, toArray, toArray
-
-
-
-
Constructor Detail
-
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
-
-
Method Detail
-
addValue
public void addValue(E value)
-
removeValue
public boolean removeValue(E value)
-
getValue
public E getValue(int index)
-
addValue
public void addValue(int index, E value)
-
getArray
public E[] getArray()
Description copied from interface:PrimitiveArrayGets the fixed-size array backing this instance.- Returns:
- the backing array
-
setArray
public void setArray(E[] array)
Description copied from interface:PrimitiveArraySets the fixed-size array backing this instance.- Parameters:
array- the new backing array
-
get
public E get(int index)
-
add
public void add(int index, E element)
-
indexOf
public int indexOf(Object o)
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classAbstractList<E>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceList<E>- Overrides:
containsin classAbstractCollection<E>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractCollection<E>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classAbstractCollection<E>
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractCollection<E>
-
defaultValue
public E defaultValue()
-
-