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

pack-priv final Class EmptySet<T>

extends AbstractMemoryEfficientMutableSet<T>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.Collection, .Comparator, .Iterator, .NoSuchElementException, .Set, org.eclipse.collections.api.block.function.Function, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.api.factory.Sets, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.set.MutableSet, 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 EmptySet<T>
public boolean
contains(Object obj)

Overrides org.eclipse.collections.impl.AbstractRichIterable.contains.

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

Returns true if the iterable has an element which responds true to element.equals(object).

public void
each(Procedure<? super T> procedure)

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

The procedure is executed for each element in the iterable.

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

Overrides org.eclipse.collections.impl.AbstractRichIterable.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.AbstractRichIterable.forEachWithIndex.

Implements 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.

public T
getFirst()

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

Returns the first element of an iterable.

public T
getLast()

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

Returns the last element of an iterable.

public T
getOnly()

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

Returns the element if the iterable has exactly one element.

public int
public Iterator<T>
iterator()

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

Returns an iterator over elements of type T.

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

Overrides org.eclipse.collections.impl.AbstractRichIterable.max.

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

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

public T
max()

Overrides org.eclipse.collections.impl.AbstractRichIterable.max.

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

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

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

Overrides org.eclipse.collections.impl.AbstractRichIterable.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.AbstractRichIterable.min.

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

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

public T
min()

Overrides org.eclipse.collections.impl.AbstractRichIterable.min.

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

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

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

Overrides org.eclipse.collections.impl.AbstractRichIterable.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 int
size()

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

Returns the number of items in this iterable.

public MutableSet<T>
with(T element)

Overrides default org.eclipse.collections.api.set.MutableSet.with.

Implements org.eclipse.collections.api.set.FixedSizeSet.with, org.eclipse.collections.api.collection.MutableCollection.with.

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

public MutableSet<T>
without(T element)

Overrides default org.eclipse.collections.api.set.MutableSet.without.

Implements org.eclipse.collections.api.set.FixedSizeSet.without, org.eclipse.collections.api.collection.MutableCollection.without.

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

public <S> MutableSet<Pair<T, S>>
zip(Iterable<S> that)

Overrides org.eclipse.collections.impl.set.mutable.AbstractMutableSet.zip.

Implements org.eclipse.collections.api.set.MutableSet.zip, org.eclipse.collections.api.collection.MutableCollection.zip, org.eclipse.collections.api.RichIterable.zip.

Deprecated in 6.0. Use OrderedIterable#zip(Iterable) instead.

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

public <S, R extends Collection<Pair<T, S>>> R
zip(Iterable<S> that, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.zip.

Implements org.eclipse.collections.api.RichIterable.zip.

Same as zip(Iterable) but uses target for output.

public MutableSet<Pair<T, Integer>>
public <R extends Collection<Pair<T, Integer>>> R
Inherited from org.eclipse.collections.impl.set.fixed.AbstractMemoryEfficientMutableSet:
addAlladdAllIterableasParallelclearnullSafeHashCoderemoveremoveAllremoveAllIterableremoveIfremoveIfWithretainAllretainAllIterabletapwithAllwithoutAll

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

EmptySetback to summary
pack-priv EmptySet()

Method Detail

cloneback to summary
public EmptySet<T> clone()

Overrides org.eclipse.collections.impl.set.mutable.AbstractMutableSet.clone.

Implements org.eclipse.collections.api.set.MutableSet.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.AbstractRichIterable.contains.

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

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

Returns true if the iterable has an element which responds true to element.equals(object).

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

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
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Implements org.eclipse.collections.api.set.SetIterable.equals, java.util.Collection.equals, java.util.Set.equals.

Doc from org.eclipse.collections.api.set.SetIterable.equals.

Follows the same general contract as Set#equals(Object).

Annotations
@Override
forEachWithback to summary
public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.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.AbstractRichIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.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
getFirstback to summary
public T getFirst()

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

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

Returns 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.

Annotations
@Override
getLastback to summary
public T getLast()

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

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

Returns 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.

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
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.eclipse.collections.api.set.SetIterable.hashCode, java.util.Collection.hashCode, java.util.Set.hashCode.

Doc from org.eclipse.collections.api.set.SetIterable.hashCode.

Follows the same general contract as Set#hashCode().

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

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

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

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

Overrides org.eclipse.collections.impl.AbstractRichIterable.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.AbstractRichIterable.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 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.AbstractRichIterable.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.AbstractRichIterable.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.AbstractRichIterable.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 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.AbstractRichIterable.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()
sizeback to summary
public int size()

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

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

Returns the number of items in this iterable.

Annotations
@Override
withback to summary
public MutableSet<T> with(T element)

Overrides default org.eclipse.collections.api.set.MutableSet.with.

Implements org.eclipse.collections.api.set.FixedSizeSet.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
withoutback to summary
public MutableSet<T> without(T element)

Overrides default org.eclipse.collections.api.set.MutableSet.without.

Implements org.eclipse.collections.api.set.FixedSizeSet.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
zipback to summary
public <S> MutableSet<Pair<T, S>> zip(Iterable<S> that)

Overrides org.eclipse.collections.impl.set.mutable.AbstractMutableSet.zip.

Implements org.eclipse.collections.api.set.MutableSet.zip, org.eclipse.collections.api.collection.MutableCollection.zip, org.eclipse.collections.api.RichIterable.zip.

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

Deprecated

in 6.0. Use OrderedIterable#zip(Iterable) instead.

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
@Deprecated
@Override
zipback to summary
public <S, R extends Collection<Pair<T, S>>> R zip(Iterable<S> that, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.zip.

Implements org.eclipse.collections.api.RichIterable.zip.

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

Same as zip(Iterable) but uses target for output.

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

Overrides org.eclipse.collections.impl.set.mutable.AbstractMutableSet.zipWithIndex.

Implements org.eclipse.collections.api.set.MutableSet.zipWithIndex, org.eclipse.collections.api.collection.MutableCollection.zipWithIndex, org.eclipse.collections.api.RichIterable.zipWithIndex.

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

Deprecated

in 6.0. Use OrderedIterable#zipWithIndex() instead.

Zips this RichIterable with its indices.

Annotations
@Deprecated
@Override
zipWithIndexback to summary
public <R extends Collection<Pair<T, Integer>>> R zipWithIndex(R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.zipWithIndex.

Implements org.eclipse.collections.api.RichIterable.zipWithIndex.

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

Same as zipWithIndex() but uses target for output.

Annotations
@Override