Class EmptyList<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.AbstractMemoryEfficientMutableList<T>
org.eclipse.collections.impl.list.fixed.EmptyList<T>
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess, SequencedCollection<T>, FixedSizeCollection<T>, MutableCollection<T>, InternalIterable<T>, FixedSizeList<T>, ListIterable<T>, MutableList<T>, OrderedIterable<T>, ReversibleIterable<T>, RichIterable<T>
This class is a memory efficient list with no elements. It is created by calling Lists.fixedSize.of() which
actually returns a singleton instance.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanReturns true if the iterable has an element which responds true to element.equals(object).voidThe procedure is executed for each element in the iterable.<P> voidforEachWith(Procedure2<? super T, ? super P> procedure, P parameter) The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.get(int index) Returns the item at the specified position in this list iterable.getFirst()Returns the first element of an iterable.getLast()Returns the last element of an iterable.getOnly()Returns the element if the iterable has exactly one element.iterator()listIterator(int index) max()Returns the maximum element out of this container based on the natural order.max(Comparator<? super T> comparator) Returns the maximum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.min()Returns the minimum element out of this container based on the natural order.min(Comparator<? super T> comparator) Returns the minimum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.private ObjectvoidreplaceAll(UnaryOperator<T> operator) intsize()Returns the number of items in this iterable.voidsort(Comparator<? super T> comparator) This method checks if comparator is null and use a ComparableComparator if it is.sortThis(Comparator<? super T> comparator) Sorts the internal data structure of this list and returns the list itself as a convenience.<V extends Comparable<? super V>>
MutableList<T> sortThisBy(Function<? super T, ? extends V> function) Sorts the internal data structure of this list based on the natural order of the attribute returned byfunction.sortThisByBoolean(BooleanFunction<? super T> function) sortThisByByte(ByteFunction<? super T> function) sortThisByChar(CharFunction<? super T> function) sortThisByDouble(DoubleFunction<? super T> function) sortThisByFloat(FloatFunction<? super T> function) sortThisByInt(IntFunction<? super T> function) sortThisByLong(LongFunction<? super T> function) sortThisByShort(ShortFunction<? super T> function) Converts thisMutableCollectionto anImmutableCollection.This method allows mutable and fixed size collections the ability to add elements to their existing elements.<S> MutableList<Pair<T, S>> Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.Zips thisRichIterablewith its indices.Methods inherited from class AbstractMemoryEfficientMutableList
add, add, addAll, addAll, addAllIterable, clear, remove, remove, removeAll, removeAllIterable, removeIf, removeIfWith, retainAll, retainAllIterable, subList, tap, toReversed, withAll, without, withoutAllMethods inherited from class AbstractMutableList
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asParallel, asReversed, asSynchronized, asUnmodifiable, binarySearch, chunk, collect, collectIf, collectWith, containsAll, corresponds, count, countWith, detect, detectIndex, detectLastIndex, detectOptional, detectWith, detectWithOptional, distinct, distinct, distinctBy, drop, dropWhile, equals, flatCollect, forEach, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, hashCode, indexOf, injectInto, injectInto, injectInto, injectInto, injectIntoWith, lastIndexOf, newEmpty, noneSatisfy, noneSatisfyWith, partition, partitionWhile, partitionWith, reject, rejectWith, removeRange, select, selectAndRejectWith, selectInstancesOf, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, toSet, toSortedList, zip, zipWithIndexMethods inherited from class AbstractMutableCollection
countBy, countByEach, countByWith, reduce, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from class AbstractRichIterable
asLazy, containsAllArguments, containsAllIterable, detectWithIfNone, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, into, isEmpty, toBag, toBiMap, toList, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface FixedSizeList
sortThisMethods inherited from interface InternalIterable
forEachMethods inherited from interface List
addFirst, addLast, containsAll, equals, hashCode, isEmpty, lastIndexOf, removeFirst, removeLast, reversed, spliteratorMethods inherited from interface ListIterable
asParallel, binarySearch, binarySearch, equals, forEachInBoth, hashCode, lastIndexOfMethods inherited from interface MutableCollection
aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, groupByUniqueKey, injectIntoWith, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from interface MutableList
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, distinct, distinct, distinctBy, drop, dropWhile, flatCollect, flatCollectWith, groupBy, groupByEach, indexOf, newEmpty, partition, partitionWhile, partitionWith, reject, rejectWith, rejectWithIndex, reverseThis, select, selectInstancesOf, selectWith, selectWithIndex, shuffleThis, shuffleThis, take, takeWhile, toArray, toArray, toImmutableListMethods inherited from interface OrderedIterable
collectWithIndex, corresponds, detectIndex, forEach, forEachWithIndex, getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndex, toStack, zip, zipWithIndexMethods inherited from interface ReversibleIterable
asReversed, detectLastIndex, reverseForEach, reverseForEachWithIndexMethods inherited from interface RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, 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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
EmptyList
EmptyList()
-
-
Method Details
-
readResolve
-
with
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:
-
clone
- Specified by:
clonein interfaceMutableList<T>- Overrides:
clonein classAbstractMemoryEfficientMutableList<T>
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein interfaceRichIterable<T>
-
contains
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceList<T>- Specified by:
containsin interfaceRichIterable<T>- Overrides:
containsin classAbstractMutableList<T>
-
get
Description copied from interface:ListIterableReturns the item at the specified position in this list iterable. -
set
-
replaceAll
- Specified by:
replaceAllin interfaceList<T>- Since:
- 10.0 - Overridden for efficiency
-
sort
Description copied from class:AbstractMemoryEfficientMutableListThis method checks if comparator is null and use a ComparableComparator if it is. -
sortThis
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>
-
sortThisBy
public <V extends Comparable<? super V>> MutableList<T> sortThisBy(Function<? super T, ? extends V> function) Description copied from interface:MutableListSorts the internal data structure of this list based on the natural order of the attribute returned byfunction.- Specified by:
sortThisByin interfaceMutableList<T>
-
sortThisByInt
- Specified by:
sortThisByIntin interfaceMutableList<T>- Overrides:
sortThisByIntin classAbstractMutableList<T>
-
sortThisByBoolean
- Specified by:
sortThisByBooleanin interfaceMutableList<T>- Overrides:
sortThisByBooleanin classAbstractMutableList<T>
-
sortThisByChar
- Specified by:
sortThisByCharin interfaceMutableList<T>- Overrides:
sortThisByCharin classAbstractMutableList<T>
-
sortThisByByte
- Specified by:
sortThisByBytein interfaceMutableList<T>- Overrides:
sortThisByBytein classAbstractMutableList<T>
-
sortThisByShort
- Specified by:
sortThisByShortin interfaceMutableList<T>- Overrides:
sortThisByShortin classAbstractMutableList<T>
-
sortThisByFloat
- Specified by:
sortThisByFloatin interfaceMutableList<T>- Overrides:
sortThisByFloatin classAbstractMutableList<T>
-
sortThisByLong
- Specified by:
sortThisByLongin interfaceMutableList<T>- Overrides:
sortThisByLongin classAbstractMutableList<T>
-
sortThisByDouble
- Specified by:
sortThisByDoublein interfaceMutableList<T>- Overrides:
sortThisByDoublein classAbstractMutableList<T>
-
getFirst
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceList<T>- Specified by:
getFirstin interfaceListIterable<T>- Specified by:
getFirstin interfaceMutableList<T>- Specified by:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Specified by:
getFirstin interfaceSequencedCollection<T>- Overrides:
getFirstin classAbstractMutableList<T>
-
getLast
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
- Specified by:
getLastin interfaceList<T>- Specified by:
getLastin interfaceListIterable<T>- Specified by:
getLastin interfaceMutableList<T>- Specified by:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>- Specified by:
getLastin interfaceSequencedCollection<T>- Overrides:
getLastin classAbstractMutableList<T>
-
getOnly
Description copied from interface:RichIterableReturns the element if the iterable has exactly one element. Otherwise, throwIllegalStateException.- Specified by:
getOnlyin interfaceRichIterable<T>- Returns:
- an element of an iterable.
-
each
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
This method is a variant ofInternalIterable.forEach(Procedure)that has a signature conflict withIterable.forEach(java.util.function.Consumer).- Specified by:
eachin interfaceRichIterable<T>- Overrides:
eachin classAbstractMutableList<T>- See Also:
-
forEachWithIndex
Description copied from interface:InternalIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractMutableList<T>
-
forEachWith
Description copied from interface:InternalIterableThe procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) -> { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } }, fred);Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);- Specified by:
forEachWithin interfaceInternalIterable<T>- Overrides:
forEachWithin classAbstractMutableList<T>
-
iterator
-
listIterator
- Specified by:
listIteratorin interfaceList<T>- Specified by:
listIteratorin interfaceListIterable<T>- Overrides:
listIteratorin classAbstractMemoryEfficientMutableList<T>- See Also:
-
listIterator
- Specified by:
listIteratorin interfaceList<T>- Specified by:
listIteratorin interfaceListIterable<T>- Overrides:
listIteratorin classAbstractMemoryEfficientMutableList<T>- See Also:
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator.- Specified by:
minin interfaceRichIterable<T>- Overrides:
minin classAbstractMutableList<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator.- Specified by:
maxin interfaceRichIterable<T>- Overrides:
maxin classAbstractMutableList<T>
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the natural order.- Specified by:
minin interfaceOrderedIterable<T>- Specified by:
minin interfaceRichIterable<T>- Overrides:
minin classAbstractMutableList<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the natural order.- Specified by:
maxin interfaceOrderedIterable<T>- Specified by:
maxin interfaceRichIterable<T>- Overrides:
maxin classAbstractMutableList<T>
-
minBy
Description copied from interface:RichIterableReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minByin interfaceRichIterable<T>- Overrides:
minByin classAbstractMutableList<T>
-
maxBy
Description copied from interface:RichIterableReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxByin interfaceRichIterable<T>- Overrides:
maxByin classAbstractMutableList<T>
-
zip
Description copied from interface:RichIterableReturns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs. If one of the twoRichIterables is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceListIterable<T>- Specified by:
zipin interfaceMutableCollection<T>- Specified by:
zipin interfaceMutableList<T>- Specified by:
zipin interfaceOrderedIterable<T>- Specified by:
zipin interfaceReversibleIterable<T>- Specified by:
zipin interfaceRichIterable<T>- Overrides:
zipin classAbstractMutableList<T>- Type Parameters:
S- the type of the second half of the returned pairs- Parameters:
that- TheRichIterableproviding the second half of each result pair- Returns:
- A new
RichIterablecontaining pairs consisting of corresponding elements of thisRichIterableand that. The length of the returnedRichIterableis the minimum of the lengths of thisRichIterableand that.
-
zipWithIndex
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceListIterable<T>- Specified by:
zipWithIndexin interfaceMutableCollection<T>- Specified by:
zipWithIndexin interfaceMutableList<T>- Specified by:
zipWithIndexin interfaceOrderedIterable<T>- Specified by:
zipWithIndexin interfaceReversibleIterable<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Overrides:
zipWithIndexin classAbstractMutableList<T>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
-
toImmutable
Description copied from interface:MutableCollectionConverts thisMutableCollectionto anImmutableCollection.- Specified by:
toImmutablein interfaceListIterable<T>- Specified by:
toImmutablein interfaceMutableCollection<T>- Specified by:
toImmutablein interfaceMutableList<T>
-