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

pack-priv final Class EmptyList<T>

extends AbstractMemoryEfficientMutableList<T>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.Comparator, .Iterator, .ListIterator, .NoSuchElementException, java.util.function.UnaryOperator, org.eclipse.collections.api.block.function.Function, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.api.factory.Lists, org.eclipse.collections.api.list.ImmutableList, .MutableList, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.EmptyIterator

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

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public EmptyList<T>
public boolean
public void
each(Procedure<? super T> procedure)

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

Implements org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

public <P> void
forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)

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

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

public void
forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)

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

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex, org.eclipse.collections.api.ordered.OrderedIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

public T
get(int index)

Implements java.util.List.get, org.eclipse.collections.api.list.ListIterable.get.

Returns the element at the specified position in this list.

public T
getFirst()

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

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

Implements org.eclipse.collections.api.RichIterable.getFirst.

This default override exists because java.util.List added a default getFirst() method in Java 21.

public T
getLast()

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

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

Implements org.eclipse.collections.api.RichIterable.getLast.

This default override exists because java.util.List added a default getLast() method in Java 21.

public T
getOnly()

Overrides default org.eclipse.collections.api.RichIterable.getOnly.

Returns the element if the iterable has exactly one element.

public Iterator<T>
public ListIterator<T>
public ListIterator<T>
listIterator(int index)

Overrides org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.listIterator.

Implements java.util.List.listIterator, org.eclipse.collections.api.list.ListIterable.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.

public T
max(Comparator<? super T> comparator)

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

Implements org.eclipse.collections.api.RichIterable.max.

Returns the maximum element out of this container based on the comparator.

public T
public <V extends Comparable<? super V>> T
maxBy(Function<? super T, ? extends V> function)

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

Implements org.eclipse.collections.api.RichIterable.maxBy.

Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.

public T
min(Comparator<? super T> comparator)

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

Implements org.eclipse.collections.api.RichIterable.min.

Returns the minimum element out of this container based on the comparator.

public T
public <V extends Comparable<? super V>> T
minBy(Function<? super T, ? extends V> function)

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

Implements org.eclipse.collections.api.RichIterable.minBy.

Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.

private Object
public void
replaceAll(UnaryOperator<T> operator)

Overrides default java.util.List.replaceAll.

Replaces each element of this list with the result of applying the operator to that element (optional operation).

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 int
size()

Implements java.util.Collection.size, org.eclipse.collections.api.RichIterable.size, java.util.List.size.

Returns the number of elements in this list.

public void
sort(Comparator<? super T> comparator)

Overrides org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.sort.

Overrides default java.util.List.sort.

This method checks if comparator is null and use a ComparableComparator if it is.

public EmptyList<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 <V extends Comparable<? super V>> MutableList<T>
sortThisBy(Function<? super T, ? extends V> function)

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

Sorts the internal data structure of this list based on the natural order of the attribute returned by function.

public MutableList<T>
public MutableList<T>
public MutableList<T>
public MutableList<T>
public MutableList<T>
public MutableList<T>
public MutableList<T>
public MutableList<T>
public ImmutableList<T>
public SingletonList<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 <S> MutableList<Pair<T, S>>
zip(Iterable<S> that)

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

Implements org.eclipse.collections.api.list.MutableList.zip, org.eclipse.collections.api.collection.MutableCollection.zip, org.eclipse.collections.api.RichIterable.zip.

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs.

public MutableList<Pair<T, Integer>>
Inherited from org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList:
addaddaddAlladdAlladdAllIterableclearremoveremoveremoveAllremoveAllIterableremoveIfremoveIfWithretainAllretainAllIterablesubListtaptoReversedwithAllwithoutwithoutAll

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

EmptyListback to summary
pack-priv EmptyList()

Method Detail

cloneback to summary
public EmptyList<T> clone()

Overrides org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.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
containsback to summary
public boolean contains(Object obj)

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

Implements java.util.Collection.contains, org.eclipse.collections.api.RichIterable.contains, java.util.List.contains.

Doc from java.util.List.contains.

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e).

Annotations
@Override
eachback to summary
public void each(Procedure<? super T> procedure)

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

Implements org.eclipse.collections.api.RichIterable.each.

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

The 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 of InternalIterable#forEach(Procedure) that has a signature conflict with Iterable#forEach(java.util.function.Consumer).
Annotations
@Override
forEachWithback to summary
public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)

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

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

Doc from org.eclipse.collections.api.InternalIterable.forEachWith.

The 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);
Annotations
@Override
forEachWithIndexback to summary
public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)

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

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex, org.eclipse.collections.api.ordered.OrderedIterable.forEachWithIndex.

Doc from org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates 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());
    }
});
Annotations
@Override
getback to summary
public T get(int index)

Implements java.util.List.get, org.eclipse.collections.api.list.ListIterable.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Annotations
@Override
getFirstback to summary
public T getFirst()

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

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

Implements org.eclipse.collections.api.RichIterable.getFirst.

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

This default override exists because java.util.List added a default getFirst() method in Java 21.

Annotations
@Override
getLastback to summary
public T getLast()

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

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

Implements org.eclipse.collections.api.RichIterable.getLast.

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

This default override exists because java.util.List added a default getLast() method in Java 21.

Annotations
@Override
getOnlyback to summary
public T getOnly()

Overrides default org.eclipse.collections.api.RichIterable.getOnly.

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

Returns the element if the iterable has exactly one element. Otherwise, throw IllegalStateException.

Annotations
@Override
iteratorback to summary
public Iterator<T> iterator()

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

Implements java.util.Collection.iterator, java.lang.Iterable.iterator, java.util.List.iterator.

Doc from java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

Annotations
@Override
listIteratorback to summary
public ListIterator<T> listIterator()

Overrides org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.listIterator.

Implements java.util.List.listIterator, org.eclipse.collections.api.list.ListIterable.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

Annotations
@Override
listIteratorback to summary
public ListIterator<T> listIterator(int index)

Overrides org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.listIterator.

Implements java.util.List.listIterator, org.eclipse.collections.api.list.ListIterable.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

Annotations
@Override
maxback to summary
public T max(Comparator<? super T> comparator)

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

Implements org.eclipse.collections.api.RichIterable.max.

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

Returns the maximum element out of this container based on the comparator.

Annotations
@Override
maxback to summary
public T max()

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

Implements org.eclipse.collections.api.RichIterable.max, org.eclipse.collections.api.ordered.OrderedIterable.max.

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

Returns the maximum element out of this container based on the natural order.

Annotations
@Override
maxByback to summary
public <V extends Comparable<? super V>> T maxBy(Function<? super T, ? extends V> function)

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

Implements org.eclipse.collections.api.RichIterable.maxBy.

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

Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.

Annotations
@Override
minback to summary
public T min(Comparator<? super T> comparator)

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

Implements org.eclipse.collections.api.RichIterable.min.

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

Returns the minimum element out of this container based on the comparator.

Annotations
@Override
minback to summary
public T min()

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

Implements org.eclipse.collections.api.RichIterable.min, org.eclipse.collections.api.ordered.OrderedIterable.min.

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

Returns the minimum element out of this container based on the natural order.

Annotations
@Override
minByback to summary
public <V extends Comparable<? super V>> T minBy(Function<? super T, ? extends V> function)

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

Implements org.eclipse.collections.api.RichIterable.minBy.

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

Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.

Annotations
@Override
readResolveback to summary
private Object readResolve()
replaceAllback to summary
public void replaceAll(UnaryOperator<T> operator)

Overrides default java.util.List.replaceAll.

Doc from java.util.List.replaceAll.

Replaces each element of this list with the result of applying the operator to that element (optional operation). Errors or runtime exceptions thrown by the operator are relayed to the caller.

Annotations
@Override
Since
10.0 - Overridden for efficiency
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
sizeback to summary
public int size()

Implements java.util.Collection.size, org.eclipse.collections.api.RichIterable.size, java.util.List.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Annotations
@Override
sortback to summary
public void sort(Comparator<? super T> comparator)

Overrides org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.sort.

Overrides default java.util.List.sort.

Doc from org.eclipse.collections.impl.list.fixed.AbstractMemoryEfficientMutableList.sort.

This method checks if comparator is null and use a ComparableComparator if it is.

Annotations
@Override
Since
10.0 - Overridden for efficiency
sortThisback to summary
public EmptyList<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
sortThisByback to summary
public <V extends Comparable<? super V>> MutableList<T> sortThisBy(Function<? super T, ? extends V> function)

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

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

Sorts the internal data structure of this list based on the natural order of the attribute returned by function.

Annotations
@Override
sortThisByBooleanback to summary
public MutableList<T> sortThisByBoolean(BooleanFunction<? super T> function)

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

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

Annotations
@Override
sortThisByByteback to summary
public MutableList<T> sortThisByByte(ByteFunction<? super T> function)

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

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

Annotations
@Override
sortThisByCharback to summary
public MutableList<T> sortThisByChar(CharFunction<? super T> function)

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

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

Annotations
@Override
sortThisByDoubleback to summary
public MutableList<T> sortThisByDouble(DoubleFunction<? super T> function)

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

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

Annotations
@Override
sortThisByFloatback to summary
public MutableList<T> sortThisByFloat(FloatFunction<? super T> function)

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

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

Annotations
@Override
sortThisByIntback to summary
public MutableList<T> sortThisByInt(IntFunction<? super T> function)

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

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

Annotations
@Override
sortThisByLongback to summary
public MutableList<T> sortThisByLong(LongFunction<? super T> function)

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

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

Annotations
@Override
sortThisByShortback to summary
public MutableList<T> sortThisByShort(ShortFunction<? super T> function)

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

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

Annotations
@Override
toImmutableback to summary
public ImmutableList<T> toImmutable()

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

Implements org.eclipse.collections.api.collection.MutableCollection.toImmutable.

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

Returns an immutable copy of this list. If the list is immutable, it returns itself.

Annotations
@Override
withback to summary
public SingletonList<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
zipback to summary
public <S> MutableList<Pair<T, S>> zip(Iterable<S> that)

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

Implements org.eclipse.collections.api.list.MutableList.zip, org.eclipse.collections.api.collection.MutableCollection.zip, org.eclipse.collections.api.RichIterable.zip.

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

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs. If one of the two RichIterables is longer than the other, its remaining elements are ignored.

Annotations
@Override
zipWithIndexback to summary
public MutableList<Pair<T, Integer>> zipWithIndex()

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

Implements org.eclipse.collections.api.list.MutableList.zipWithIndex, org.eclipse.collections.api.collection.MutableCollection.zipWithIndex, org.eclipse.collections.api.RichIterable.zipWithIndex.

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

Zips this RichIterable with its indices.

Annotations
@Override