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

pack-priv final Class DoubletonSet<T>

extends AbstractMemoryEfficientMutableSet<T>
implements Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable
Imports
java.io.Externalizable, .IOException, .ObjectInput, .ObjectOutput, 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.set.MutableSet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
pack-priv
DoubletonSet(T obj1, T obj2)

Method Summary

Modifier and TypeMethod and Description
public DoubletonSet<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 void
readExternal(ObjectInput in)

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.

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 void
writeExternal(ObjectOutput out)

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Inherited from org.eclipse.collections.impl.set.fixed.AbstractMemoryEfficientMutableSet:
addAlladdAllIterableasParallelclearnullSafeHashCoderemoveremoveAllremoveAllIterableremoveIfremoveIfWithretainAllretainAllIterabletapwithAllwithoutAll

Field Detail

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

Constructor Detail

DoubletonSetback to summary
public DoubletonSet()
Annotations
@SuppressWarnings:UnusedDeclaration
DoubletonSetback to summary
pack-priv DoubletonSet(T obj1, T obj2)

Method Detail

cloneback to summary
public DoubletonSet<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 o)

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
readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Doc from java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Annotations
@Override
Exceptions
IOException:
if I/O errors occur
ClassNotFoundException:
If the class for an object being restored cannot be found.
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
writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Doc from java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Annotations
@Override
Exceptions
IOException:
Includes any I/O exceptions that may occur
org.eclipse.collections.impl.set.fixed back to summary

private Class DoubletonSet.DoubletonSetIterator

extends AbstractMemoryEfficientMutableSet<T>.MemoryEfficientSetIterator
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected T
Inherited from org.eclipse.collections.impl.set.fixed.AbstractMemoryEfficientMutableSet.MemoryEfficientSetIterator:
hasNextnextremove

Constructor Detail

DoubletonSetIteratorback to summary
private DoubletonSetIterator()

Method Detail

getElementback to summary
protected T getElement(int i)

Implements abstract org.eclipse.collections.impl.set.fixed.AbstractMemoryEfficientMutableSet.MemoryEfficientSetIterator.getElement.

Annotations
@Override