Class ArrayAdapter<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection<T>
-
- org.eclipse.collections.impl.list.mutable.AbstractMutableList<T>
-
- org.eclipse.collections.impl.list.fixed.AbstractArrayAdapter<T>
-
- org.eclipse.collections.impl.list.fixed.ArrayAdapter<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<T>,java.util.Collection<T>,java.util.List<T>,java.util.RandomAccess,FixedSizeCollection<T>,MutableCollection<T>,InternalIterable<T>,FixedSizeList<T>,ListIterable<T>,MutableList<T>,OrderedIterable<T>,ReversibleIterable<T>,RichIterable<T>
public final class ArrayAdapter<T> extends AbstractArrayAdapter<T> implements java.io.Serializable, FixedSizeList<T>
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 asAbstractMutableCollection.add(Object),AbstractArrayAdapter.addAll(Collection),AbstractArrayAdapter.remove(Object),AbstractArrayAdapter.removeAll(Collection), etc. are not supported and will throw anUnsupportedOperationException. In addition, the mutating iteration methodsAbstractArrayAdapter.removeIf(org.eclipse.collections.api.block.predicate.Predicate)andAbstractArrayAdapter.removeIfWith(org.eclipse.collections.api.block.predicate.Predicate2, Object)are not supported and will also throw anUnsupportedOperationException.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 thenewArray(Iterable)ornewArrayWithItem(Iterable, Object)factory methods. To wrap existing objects in a new array, use one of thenewArrayWith(Object)factory methods.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.collections.impl.list.mutable.AbstractMutableList
AbstractMutableList.SubList<T>
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Object[]EMPTY_ARRAYprivate static longserialVersionUID-
Fields inherited from class org.eclipse.collections.impl.list.fixed.AbstractArrayAdapter
items
-
-
Constructor Summary
Constructors Modifier Constructor Description privateArrayAdapter(T[] newElements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> ArrayAdapter<E>adapt(E... array)ArrayAdapter<T>clone()static <E> ArrayAdapter<E>newArray()static <E> ArrayAdapter<E>newArray(java.lang.Iterable<? extends E> source)static <E> ArrayAdapter<E>newArrayWith(E one)static <E> ArrayAdapter<E>newArrayWith(E... elements)static <E> ArrayAdapter<E>newArrayWith(E one, E two)static <E> ArrayAdapter<E>newArrayWith(E one, E two, E three)static <E> ArrayAdapter<E>newArrayWith(E one, E two, E three, E four)static <E> ArrayAdapter<E>newArrayWith(E one, E two, E three, E four, E five)static <E> ArrayAdapter<E>newArrayWith(E one, E two, E three, E four, E five, E six)static <E> ArrayAdapter<E>newArrayWith(E one, E two, E three, E four, E five, E six, E seven)static <E> ArrayAdapter<E>newArrayWithItem(java.lang.Iterable<? extends E> iterable, E itemToAdd)private voidreadObject(java.io.ObjectInputStream objectInputStream)Tset(int index, T element)ArrayAdapter<T>sortThis(java.util.Comparator<? super T> comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.java.util.Spliterator<T>spliterator()FixedSizeList<T>tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returnsthis.FixedSizeList<T>toReversed()Returns a new MutableList in reverse order.ArrayAdapter<T>with(T value)This method allows mutable and fixed size collections the ability to add elements to their existing elements.ArrayAdapter<T>withAll(java.lang.Iterable<? extends T> elements)This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.ArrayAdapter<T>without(T element)This method allows mutable and fixed size collections the ability to remove elements from their existing elements.ArrayAdapter<T>withoutAll(java.lang.Iterable<? extends T> elements)This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.private voidwriteObject(java.io.ObjectOutputStream objectOutputStream)-
Methods inherited from class org.eclipse.collections.impl.list.fixed.AbstractArrayAdapter
abstractArrayAdapterEquals, add, addAll, addAll, addAllIterable, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, clear, collect, collect, collectIf, collectWith, collectWith, contains, corresponds, count, countWith, detect, detectIndex, detectLastIndex, detectOptional, detectWith, detectWithOptional, distinct, distinct, drop, each, equals, flatCollect, flatCollect, forEach, forEachWith, forEachWithIndex, forEachWithIndex, get, getFirst, getLast, hashCode, indexOf, injectInto, injectIntoWith, isEmpty, iterator, lastIndexOf, listIterator, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, remove, remove, removeAll, removeAllIterable, removeIf, removeIfWith, replaceAll, retainAll, retainAllIterable, select, selectAndRejectWith, selectWith, size, sort, subList, take, toArray, toArray
-
Methods inherited from class org.eclipse.collections.impl.list.mutable.AbstractMutableList
appendString, asParallel, asReversed, asSynchronized, asUnmodifiable, binarySearch, chunk, containsAll, distinctBy, dropWhile, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, listIterator, max, max, maxBy, min, min, minBy, newEmpty, partition, partitionWhile, partitionWith, removeRange, selectInstancesOf, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, takeWhile, toSet, toSortedList, zip, zip, zipWithIndex, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
add, countBy, countByEach, countByWith, reduce, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
asLazy, containsAllArguments, containsAllIterable, detectWithIfNone, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, into, toBag, toBiMap, toList, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.collection.FixedSizeCollection
add, addAll, addAllIterable, clear, remove, removeAll, removeAllIterable, removeIf, removeIfWith, retainAll, retainAllIterable
-
Methods inherited from interface org.eclipse.collections.api.list.FixedSizeList
sortThis
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, size, sort
-
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
asParallel, binarySearch, binarySearch, equals, forEachInBoth, get, hashCode, lastIndexOf, listIterator, listIterator
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, groupByUniqueKey, injectIntoWith, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.list.MutableList
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, distinct, distinct, distinctBy, drop, dropWhile, flatCollect, flatCollectWith, getFirst, getLast, groupBy, groupByEach, indexOf, newEmpty, partition, partitionWhile, partitionWith, reject, rejectWith, rejectWithIndex, reverseThis, select, selectInstancesOf, selectWith, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, subList, take, takeWhile, toArray, toArray, toImmutable, toImmutableList, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, corresponds, detectIndex, forEach, forEachWithIndex, forEachWithIndex, getFirstOptional, getLastOptional, max, min, rejectWithIndex, selectWithIndex, toStack, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
asReversed, detectLastIndex, reverseForEach, reverseForEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
EMPTY_ARRAY
private static final java.lang.Object[] EMPTY_ARRAY
-
-
Constructor Detail
-
ArrayAdapter
private ArrayAdapter(T[] newElements)
-
-
Method Detail
-
adapt
public static <E> ArrayAdapter<E> adapt(E... array)
-
newArray
public static <E> ArrayAdapter<E> newArray()
-
newArray
public static <E> ArrayAdapter<E> newArray(java.lang.Iterable<? extends E> source)
-
spliterator
public java.util.Spliterator<T> spliterator()
-
newArrayWithItem
public static <E> ArrayAdapter<E> newArrayWithItem(java.lang.Iterable<? extends E> iterable, E itemToAdd)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one, E two)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four, E five)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four, E five, E six)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E one, E two, E three, E four, E five, E six, E seven)
-
newArrayWith
public static <E> ArrayAdapter<E> newArrayWith(E... elements)
-
with
public ArrayAdapter<T> with(T value)
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.with("1"); list = list.with("2"); return list;In the case ofFixedSizeCollectiona new instance of MutableCollection will be returned by with, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling add on itself.- Specified by:
within interfaceFixedSizeCollection<T>- Specified by:
within interfaceFixedSizeList<T>- Specified by:
within interfaceMutableCollection<T>- Specified by:
within interfaceMutableList<T>- See Also:
Collection.add(Object)
-
without
public ArrayAdapter<T> without(T element)
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.without("1"); list = list.without("2"); return list;In the case ofFixedSizeCollectiona new instance of MutableCollection will be returned by without, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling remove on itself.- Specified by:
withoutin interfaceFixedSizeCollection<T>- Specified by:
withoutin interfaceFixedSizeList<T>- Specified by:
withoutin interfaceMutableCollection<T>- Specified by:
withoutin interfaceMutableList<T>- See Also:
Collection.remove(Object)
-
withAll
public ArrayAdapter<T> withAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));In the case ofFixedSizeCollectiona new instance of MutableCollection will be returned by withAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling addAll on itself.- Specified by:
withAllin interfaceFixedSizeCollection<T>- Specified by:
withAllin interfaceFixedSizeList<T>- Specified by:
withAllin interfaceMutableCollection<T>- Specified by:
withAllin interfaceMutableList<T>- See Also:
Collection.addAll(Collection)
-
withoutAll
public ArrayAdapter<T> withoutAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));In the case ofFixedSizeCollectiona new instance of MutableCollection will be returned by withoutAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling removeAll on itself.- Specified by:
withoutAllin interfaceFixedSizeCollection<T>- Specified by:
withoutAllin interfaceFixedSizeList<T>- Specified by:
withoutAllin interfaceMutableCollection<T>- Specified by:
withoutAllin interfaceMutableList<T>- See Also:
Collection.removeAll(Collection)
-
clone
public ArrayAdapter<T> clone()
- Specified by:
clonein interfaceMutableList<T>- Overrides:
clonein classAbstractMutableList<T>
-
sortThis
public ArrayAdapter<T> sortThis(java.util.Comparator<? super T> comparator)
Description copied from interface:MutableListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceFixedSizeList<T>- Specified by:
sortThisin interfaceMutableList<T>
-
tap
public FixedSizeList<T> tap(Procedure<? super T> procedure)
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceFixedSizeCollection<T>- Specified by:
tapin interfaceFixedSizeList<T>- Specified by:
tapin interfaceListIterable<T>- Specified by:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceMutableList<T>- Specified by:
tapin interfaceOrderedIterable<T>- Specified by:
tapin interfaceReversibleIterable<T>- Specified by:
tapin interfaceRichIterable<T>- Overrides:
tapin classAbstractMutableList<T>- See Also:
RichIterable.each(Procedure),RichIterable.forEach(Procedure)
-
toReversed
public FixedSizeList<T> toReversed()
Description copied from interface:MutableListReturns a new MutableList in reverse order.- Specified by:
toReversedin interfaceFixedSizeList<T>- Specified by:
toReversedin interfaceListIterable<T>- Specified by:
toReversedin interfaceMutableList<T>- Specified by:
toReversedin interfaceReversibleIterable<T>
-
writeObject
private void writeObject(java.io.ObjectOutputStream objectOutputStream) throws java.io.IOException- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream objectInputStream) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-