Top Inners Fields Constructors Methods
org.eclipse.collections.impl.set.immutable

pack-priv final Class ImmutableSingletonSet<T>

extends AbstractImmutableSet<T>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.Iterator, .NoSuchElementException, .Objects, .Set, 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.set.ImmutableSet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final T
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
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
equals(Object other)

Overrides java.lang.Object.equals.

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

Compares the specified object with this set for equality.

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.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.

public ImmutableSet<T>
newWith(T element)

Overrides org.eclipse.collections.impl.set.immutable.AbstractImmutableSet.newWith.

Implements org.eclipse.collections.api.set.ImmutableSet.newWith, org.eclipse.collections.api.collection.ImmutableCollection.newWith.

This method is similar to the with method in MutableCollection with the difference that a new copy of this collection with the element appended will be returned.

public ImmutableSet<T>
newWithout(T element)

Overrides org.eclipse.collections.impl.set.immutable.AbstractImmutableSet.newWithout.

Implements org.eclipse.collections.api.set.ImmutableSet.newWithout, org.eclipse.collections.api.collection.ImmutableCollection.newWithout.

This method is similar to the without method in MutableCollection with the difference that a new copy of this collection with the element removed will be returned.

public int
size()

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

Returns the number of elements in this set (its cardinality).

private Object
Inherited from org.eclipse.collections.impl.set.immutable.AbstractImmutableSet:
asParallelcartesianProductcastToSetcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithdifferencedifferenceIntoflatCollectgroupBygroupBygroupByEachgroupByEachintersectintersectIntoisProperSubsetOfisSubsetOfnewMutablenewWithAllnewWithoutAllnullSafeHashCodepartitionpartitionWithpowerSetrejectrejectWithselectselectInstancesOfselectWithsymmetricDifferencesymmetricDifferenceIntotaptoImmutableunionunionIntozipzipWithIndex

Field Detail

element1back to summary
private final T element1
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ImmutableSingletonSetback to summary
pack-priv ImmutableSingletonSet(T obj1)

Method Detail

containsback to summary
public boolean contains(Object obj)

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

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

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

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.Set.equals, java.util.Collection.equals.

Doc from java.util.Set.equals.

Compares the specified object with this set for equality. Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set). This definition ensures that the equals method works properly across different implementations of the set interface.

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.Set.hashCode, java.util.Collection.hashCode.

Doc from java.util.Set.hashCode.

Returns the hash code value for this set. The hash code of a set is defined to be the sum of the hash codes of the elements in the set, where the hash code of a null element is defined to be zero. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two sets s1 and s2, as required by the general contract of Object#hashCode.

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

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

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Annotations
@Override
newWithback to summary
public ImmutableSet<T> newWith(T element)

Overrides org.eclipse.collections.impl.set.immutable.AbstractImmutableSet.newWith.

Implements org.eclipse.collections.api.set.ImmutableSet.newWith, org.eclipse.collections.api.collection.ImmutableCollection.newWith.

Doc from org.eclipse.collections.api.collection.ImmutableCollection.newWith.

This method is similar to the with method in MutableCollection with the difference that a new copy of this collection with the element appended will be returned.

Annotations
@Override
newWithoutback to summary
public ImmutableSet<T> newWithout(T element)

Overrides org.eclipse.collections.impl.set.immutable.AbstractImmutableSet.newWithout.

Implements org.eclipse.collections.api.set.ImmutableSet.newWithout, org.eclipse.collections.api.collection.ImmutableCollection.newWithout.

Doc from org.eclipse.collections.api.collection.ImmutableCollection.newWithout.

This method is similar to the without method in MutableCollection with the difference that a new copy of this collection with the element removed will be returned.

Annotations
@Override
sizeback to summary
public int size()

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

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Annotations
@Override
writeReplaceback to summary
private Object writeReplace()
org.eclipse.collections.impl.set.immutable back to summary

private Class ImmutableSingletonSet.SingletonSetIterator

extends AbstractImmutableSet<T>.ImmutableSetIterator
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected T
Inherited from org.eclipse.collections.impl.set.immutable.AbstractImmutableSet.ImmutableSetIterator:
hasNextnextremove

Constructor Detail

SingletonSetIteratorback to summary
private SingletonSetIterator()

Method Detail

getElementback to summary
protected T getElement(int i)

Implements abstract org.eclipse.collections.impl.set.immutable.AbstractImmutableSet.ImmutableSetIterator.getElement.

Annotations
@Override