Top Description Fields Constructors Methods
org.eclipse.collections.impl.list.fixed

public final Class ArrayAdapter<T>

extends AbstractArrayAdapter<T>
implements Serializable, FixedSizeList<T>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.list.FixedSizeList, org.eclipse.collections.api.collection.FixedSizeCollection, org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable, java.util.Collection, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.list.ListIterable, org.eclipse.collections.api.ordered.ReversibleIterable, org.eclipse.collections.api.ordered.OrderedIterable, java.lang.Cloneable, java.util.List, java.util.SequencedCollection, java.io.Serializable
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.util.Collection, .Comparator, .Spliterator, .Spliterators, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.list.FixedSizeList, org.eclipse.collections.impl.block.factory.Predicates2, org.eclipse.collections.impl.utility.Iterate

This class provides a MutableList wrapper around an array. All the internal iteration methods of the MutableList interface as well as the JDK Collections List interface are provided. However, the pre-determined fixed-sized semantics of an array are maintained and thus mutating List interface methods such as add(Object), addAll(Collection), remove(Object), removeAll(Collection), etc. are not supported and will throw an UnsupportedOperationException. In addition, the mutating iteration methods removeIf(org.eclipse.collections.api.block.predicate.Predicate) and removeIfWith(org.eclipse.collections.api.block.predicate.Predicate2, Object) are not supported and will also throw an UnsupportedOperationException.

The with(Object) method is not an exception to the above restrictions, as it will create a new instance of this class with the existing contents plus the new item.

To create a wrapper around an existing array, use the adapt(Object[]) factory method. To wrap the contents of an existing Collection instance, use the newArray(Iterable) or newArrayWithItem(Iterable, Object) factory methods. To wrap existing objects in a new array, use one of the newArrayWith(Object) factory methods.

Field Summary

Modifier and TypeField and Description
private static final Object[]
private static final long
Inherited from org.eclipse.collections.impl.list.fixed.AbstractArrayAdapter:
items

Constructor Summary

AccessConstructor and Description
private
ArrayAdapter(T[] newElements)

Method Summary

Modifier and TypeMethod and Description
public static <E> ArrayAdapter<E>
adapt(E... array)

public ArrayAdapter<T>
public static <E> ArrayAdapter<E>
public static <E> ArrayAdapter<E>
newArray(Iterable<? extends E> source)

public static <E> ArrayAdapter<E>
newArrayWith(E one)

public static <E> ArrayAdapter<E>
newArrayWith(E one, E two)

public static <E> ArrayAdapter<E>
newArrayWith(E one, E two, E three)

public static <E> ArrayAdapter<E>
newArrayWith(E one, E two, E three, E four)

public static <E> ArrayAdapter<E>
newArrayWith(E one, E two, E three, E four, E five)

public static <E> ArrayAdapter<E>
newArrayWith(E one, E two, E three, E four, E five, E six)

public static <E> ArrayAdapter<E>
newArrayWith(E one, E two, E three, E four, E five, E six, E seven)

public static <E> ArrayAdapter<E>
newArrayWith(E... elements)

public static <E> ArrayAdapter<E>
newArrayWithItem(Iterable<? extends E> iterable, E itemToAdd)

private void
readObject(ObjectInputStream objectInputStream)

public T
set(int index, T element)

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

public ArrayAdapter<T>
sortThis(Comparator<? super T> comparator)

Overrides default org.eclipse.collections.api.list.FixedSizeList.sortThis, org.eclipse.collections.api.list.MutableList.sortThis.

Sorts the internal data structure of this list and returns the list itself as a convenience.

public Spliterator<T>
public FixedSizeList<T>
public FixedSizeList<T>
public ArrayAdapter<T>
with(T value)

Overrides default org.eclipse.collections.api.list.MutableList.with.

Implements org.eclipse.collections.api.list.FixedSizeList.with, org.eclipse.collections.api.collection.MutableCollection.with.

This method allows fixed size collections the ability to add elements to their existing elements.

public ArrayAdapter<T>
withAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.list.MutableList.withAll.

Implements org.eclipse.collections.api.list.FixedSizeList.withAll, org.eclipse.collections.api.collection.MutableCollection.withAll.

This method allows fixed size collections the ability to add multiple elements to their existing elements.

public ArrayAdapter<T>
without(T element)

Overrides default org.eclipse.collections.api.list.MutableList.without.

Implements org.eclipse.collections.api.list.FixedSizeList.without, org.eclipse.collections.api.collection.MutableCollection.without.

This method allows fixed size collections the ability to remove elements from their existing elements.

public ArrayAdapter<T>
withoutAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.list.MutableList.withoutAll.

Implements org.eclipse.collections.api.list.FixedSizeList.withoutAll, org.eclipse.collections.api.collection.MutableCollection.withoutAll.

This method allows fixed size collections the ability to remove multiple elements from their existing elements.

private void
writeObject(ObjectOutputStream objectOutputStream)

Inherited from org.eclipse.collections.impl.list.fixed.AbstractArrayAdapter:
abstractArrayAdapterEqualsaddaddAlladdAlladdAllIterableallSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringclearcollectcollectcollectIfcollectWithcollectWithcontainscorrespondscountcountWithdetectdetectIndexdetectLastIndexdetectOptionaldetectWithdetectWithOptionaldistinctdistinctdropeachequalsflatCollectflatCollectforEachforEachWithforEachWithIndexforEachWithIndexgetgetFirstgetLasthashCodeindexOfinjectIntoinjectIntoWithisEmptyiteratorlastIndexOflistIteratornoneSatisfynoneSatisfyWithnotEmptyrejectrejectWithremoveremoveremoveAllremoveAllIterableremoveIfremoveIfWithreplaceAllretainAllretainAllIterableselectselectAndRejectWithselectWithsizesortsubListtaketoArraytoArray

Field Detail

EMPTY_ARRAYback to summary
private static final Object[] EMPTY_ARRAY
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ArrayAdapterback to summary
private ArrayAdapter(T[] newElements)

Method Detail

adaptback to summary
public static <E> ArrayAdapter<E> adapt(E... array)
cloneback to summary
public ArrayAdapter<T> clone()

Overrides org.eclipse.collections.impl.list.mutable.AbstractMutableList.clone.

Implements org.eclipse.collections.api.list.MutableList.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Annotations
@Override
newArrayback to summary
public static <E> ArrayAdapter<E> newArray()
newArrayback to summary
public static <E> ArrayAdapter<E> newArray(Iterable<? extends E> source)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one, E two)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four, E five)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four, E five, E six)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four, E five, E six, E seven)
newArrayWithback to summary
public static <E> ArrayAdapter<E> newArrayWith(E... elements)
newArrayWithItemback to summary
public static <E> ArrayAdapter<E> newArrayWithItem(Iterable<? extends E> iterable, E itemToAdd)
readObjectback to summary
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException
setback to summary
public T set(int index, T element)

Implements java.util.List.set.

Doc from java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Annotations
@Override
sortThisback to summary
public ArrayAdapter<T> sortThis(Comparator<? super T> comparator)

Overrides default org.eclipse.collections.api.list.FixedSizeList.sortThis, org.eclipse.collections.api.list.MutableList.sortThis.

Doc from org.eclipse.collections.api.list.MutableList.sortThis.

Sorts the internal data structure of this list and returns the list itself as a convenience.

Annotations
@Override
spliteratorback to summary
public Spliterator<T> spliterator()

Overrides default java.util.Collection.spliterator, java.lang.Iterable.spliterator, java.util.List.spliterator.

Doc from java.util.List.spliterator.

Creates a Spliterator over the elements in this list.

The Spliterator reports Spliterator#SIZED and Spliterator#ORDERED. Implementations should document the reporting of additional characteristic values.

Annotations
@Override
Since
8.1
tapback to summary
public FixedSizeList<T> tap(Procedure<? super T> procedure)

Overrides org.eclipse.collections.impl.list.mutable.AbstractMutableList.tap.

Overrides default org.eclipse.collections.api.list.MutableList.tap.

Implements org.eclipse.collections.api.list.FixedSizeList.tap, org.eclipse.collections.api.collection.MutableCollection.tap, org.eclipse.collections.api.RichIterable.tap.

Doc from org.eclipse.collections.api.RichIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
toReversedback to summary
public FixedSizeList<T> toReversed()

Overrides default org.eclipse.collections.api.list.MutableList.toReversed.

Implements org.eclipse.collections.api.list.FixedSizeList.toReversed.

Doc from org.eclipse.collections.api.list.MutableList.toReversed.

Returns a new MutableList in reverse order.

Annotations
@Override
withback to summary
public ArrayAdapter<T> with(T value)

Overrides default org.eclipse.collections.api.list.MutableList.with.

Implements org.eclipse.collections.api.list.FixedSizeList.with, org.eclipse.collections.api.collection.MutableCollection.with.

Doc from org.eclipse.collections.api.collection.FixedSizeCollection.with.

This method allows fixed size collections the ability to add elements to their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with the new element added. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.with("1");
list = list.with("2");
return list;
Annotations
@Override
withAllback to summary
public ArrayAdapter<T> withAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.list.MutableList.withAll.

Implements org.eclipse.collections.api.list.FixedSizeList.withAll, org.eclipse.collections.api.collection.MutableCollection.withAll.

Doc from org.eclipse.collections.api.collection.FixedSizeCollection.withAll.

This method allows fixed size collections the ability to add multiple elements to their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with all the new elements addAll(Collection) added. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.withAll(FastList.newListWith("1", "2"));
return list;
Annotations
@Override
withoutback to summary
public ArrayAdapter<T> without(T element)

Overrides default org.eclipse.collections.api.list.MutableList.without.

Implements org.eclipse.collections.api.list.FixedSizeList.without, org.eclipse.collections.api.collection.MutableCollection.without.

Doc from org.eclipse.collections.api.collection.FixedSizeCollection.without.

This method allows fixed size collections the ability to remove elements from their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with the element removed. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.without("1");
list = list.without("2");
return list;
Annotations
@Override
withoutAllback to summary
public ArrayAdapter<T> withoutAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.list.MutableList.withoutAll.

Implements org.eclipse.collections.api.list.FixedSizeList.withoutAll, org.eclipse.collections.api.collection.MutableCollection.withoutAll.

Doc from org.eclipse.collections.api.collection.FixedSizeCollection.withoutAll.

This method allows fixed size collections the ability to remove multiple elements from their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with the given elements removed. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.withoutAll(FastList.newListWith("1", "2"));
return list;
Annotations
@Override
writeObjectback to summary
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException