Top Description Methods
org.eclipse.collections.api.set

public Interface ImmutableSet<T>

extends UnsortedSetIterable<T>, ImmutableSetIterable<T>
Imports
java.util.Set, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.multimap.set.ImmutableSetMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.set.PartitionImmutableSet, org.eclipse.collections.api.set.primitive.ImmutableBooleanSet, .ImmutableByteSet, .ImmutableCharSet, .ImmutableDoubleSet, .ImmutableFloatSet, .ImmutableIntSet, .ImmutableLongSet, .ImmutableShortSet, org.eclipse.collections.api.tuple.Pair

ImmutableSet is the non-modifiable equivalent interface to MutableSet. MutableSet#toImmutable() will give you an appropriately trimmed implementation of ImmutableSet. All ImmutableSet implementations must implement the java.util.Set interface in order to satisfy the equals() contract and be compared against other set structures like UnifiedSet or HashSet.

Method Summary

Modifier and TypeMethod and Description
public Set<T>
public <V> ImmutableSet<V>
collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collect, org.eclipse.collections.api.RichIterable.collect, org.eclipse.collections.api.collection.ImmutableCollection.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection.

public ImmutableBooleanSet
collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectBoolean, org.eclipse.collections.api.RichIterable.collectBoolean, org.eclipse.collections.api.collection.ImmutableCollection.collectBoolean.

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection.

public ImmutableByteSet
collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectByte, org.eclipse.collections.api.RichIterable.collectByte, org.eclipse.collections.api.collection.ImmutableCollection.collectByte.

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection.

public ImmutableCharSet
collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectChar, org.eclipse.collections.api.RichIterable.collectChar, org.eclipse.collections.api.collection.ImmutableCollection.collectChar.

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection.

public ImmutableDoubleSet
collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectDouble, org.eclipse.collections.api.RichIterable.collectDouble, org.eclipse.collections.api.collection.ImmutableCollection.collectDouble.

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection.

public ImmutableFloatSet
collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectFloat, org.eclipse.collections.api.RichIterable.collectFloat, org.eclipse.collections.api.collection.ImmutableCollection.collectFloat.

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection.

public <V> ImmutableSet<V>
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectIf, org.eclipse.collections.api.RichIterable.collectIf, org.eclipse.collections.api.collection.ImmutableCollection.collectIf.

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.

public ImmutableIntSet
collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectInt, org.eclipse.collections.api.RichIterable.collectInt, org.eclipse.collections.api.collection.ImmutableCollection.collectInt.

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection.

public ImmutableLongSet
collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectLong, org.eclipse.collections.api.RichIterable.collectLong, org.eclipse.collections.api.collection.ImmutableCollection.collectLong.

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection.

public ImmutableShortSet
collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectShort, org.eclipse.collections.api.RichIterable.collectShort, org.eclipse.collections.api.collection.ImmutableCollection.collectShort.

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection.

public <P, V> ImmutableSet<V>
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectWith, org.eclipse.collections.api.RichIterable.collectWith, org.eclipse.collections.api.collection.ImmutableCollection.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

public ImmutableSet<T>
difference(SetIterable<? extends T> subtrahendSet)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.difference, org.eclipse.collections.api.set.SetIterable.difference.

Returns the set of all members of this that are not members of subtrahendSet.

public <V> ImmutableSet<V>
public default <P, V> ImmutableSet<V>
flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.set.UnsortedSetIterable.flatCollectWith, org.eclipse.collections.api.RichIterable.flatCollectWith, org.eclipse.collections.api.collection.ImmutableCollection.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

public <V> ImmutableSetMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupBy, org.eclipse.collections.api.set.ImmutableSetIterable.groupBy.

For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.

public <V> ImmutableSetMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupByEach, org.eclipse.collections.api.set.ImmutableSetIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

public ImmutableSet<T>
intersect(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.intersect, org.eclipse.collections.api.set.SetIterable.intersect.

Returns the set of all objects that are members of both this and set.

public ImmutableSet<T>
newWith(T element)

Redeclares 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>
newWithAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.ImmutableCollection.newWithAll.

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

public ImmutableSet<T>
newWithout(T element)

Redeclares 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 ImmutableSet<T>
newWithoutAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.ImmutableCollection.newWithoutAll.

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

public PartitionImmutableSet<T>
partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.partition, org.eclipse.collections.api.set.ImmutableSetIterable.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

public <P> PartitionImmutableSet<T>
partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.partitionWith, org.eclipse.collections.api.set.ImmutableSetIterable.partitionWith.

Filters a collection into a PartitionIterable based on the evaluation of the predicate.

public ImmutableSet<UnsortedSetIterable<T>>
powerSet()

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.powerSet.

Returns the set whose members are all possible subsets of this.

public ImmutableSet<T>
reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.reject, org.eclipse.collections.api.set.ImmutableSetIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate.

public <P> ImmutableSet<T>
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.rejectWith, org.eclipse.collections.api.set.ImmutableSetIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public ImmutableSet<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.select, org.eclipse.collections.api.set.ImmutableSetIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate.

public <S> ImmutableSet<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectInstancesOf, org.eclipse.collections.api.set.ImmutableSetIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public <P> ImmutableSet<T>
selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectWith, org.eclipse.collections.api.set.ImmutableSetIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public ImmutableSet<T>
symmetricDifference(SetIterable<? extends T> setB)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.symmetricDifference, org.eclipse.collections.api.set.SetIterable.symmetricDifference.

Returns the set of all objects that are a member of exactly one of this and setB (elements which are in one of the sets, but not in both).

public ImmutableSet<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.tap, org.eclipse.collections.api.set.ImmutableSetIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

public default ImmutableSet<T>
toImmutableSet()

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

Overrides toImmutableSet in RichIterable to return this.

public ImmutableSet<T>
union(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.union, org.eclipse.collections.api.set.SetIterable.union.

Returns the set of all objects that are a member of this or set or both.

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

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.zip, org.eclipse.collections.api.RichIterable.zip, org.eclipse.collections.api.collection.ImmutableCollection.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 ImmutableSet<Pair<T, Integer>>
Inherited from org.eclipse.collections.api.set.UnsortedSetIterable:
asParalleltoImmutable

Method Detail

castToSetback to summary
public Set<T> castToSet()
collectback to summary
public <V> ImmutableSet<V> collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collect, org.eclipse.collections.api.RichIterable.collect, org.eclipse.collections.api.collection.ImmutableCollection.collect.

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

Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

RichIterable<String> names =
    people.collect(person -> person.getFirstName() + " " + person.getLastName());
Annotations
@Override
collectBooleanback to summary
public ImmutableBooleanSet collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectBoolean, org.eclipse.collections.api.RichIterable.collectBoolean, org.eclipse.collections.api.collection.ImmutableCollection.collectBoolean.

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

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

BooleanIterable licenses =
    people.collectBoolean(person -> person.hasDrivingLicense());
Annotations
@Override
collectByteback to summary
public ImmutableByteSet collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectByte, org.eclipse.collections.api.RichIterable.collectByte, org.eclipse.collections.api.collection.ImmutableCollection.collectByte.

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

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

ByteIterable bytes =
    people.collectByte(person -> person.getCode());
Annotations
@Override
collectCharback to summary
public ImmutableCharSet collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectChar, org.eclipse.collections.api.RichIterable.collectChar, org.eclipse.collections.api.collection.ImmutableCollection.collectChar.

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

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

CharIterable chars =
    people.collectChar(person -> person.getMiddleInitial());
Annotations
@Override
collectDoubleback to summary
public ImmutableDoubleSet collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectDouble, org.eclipse.collections.api.RichIterable.collectDouble, org.eclipse.collections.api.collection.ImmutableCollection.collectDouble.

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

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

DoubleIterable doubles =
    people.collectDouble(person -> person.getMilesFromNorthPole());
Annotations
@Override
collectFloatback to summary
public ImmutableFloatSet collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectFloat, org.eclipse.collections.api.RichIterable.collectFloat, org.eclipse.collections.api.collection.ImmutableCollection.collectFloat.

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

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

FloatIterable floats =
    people.collectFloat(person -> person.getHeightInInches());
Annotations
@Override
collectIfback to summary
public <V> ImmutableSet<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectIf, org.eclipse.collections.api.RichIterable.collectIf, org.eclipse.collections.api.collection.ImmutableCollection.collectIf.

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

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function).

Example using a Java 8 lambda and method reference:

RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);

Example using Predicates factory:

RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
Annotations
@Override
collectIntback to summary
public ImmutableIntSet collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectInt, org.eclipse.collections.api.RichIterable.collectInt, org.eclipse.collections.api.collection.ImmutableCollection.collectInt.

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

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

IntIterable ints =
    people.collectInt(person -> person.getAge());
Annotations
@Override
collectLongback to summary
public ImmutableLongSet collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectLong, org.eclipse.collections.api.RichIterable.collectLong, org.eclipse.collections.api.collection.ImmutableCollection.collectLong.

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

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

LongIterable longs =
    people.collectLong(person -> person.getGuid());
Annotations
@Override
collectShortback to summary
public ImmutableShortSet collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectShort, org.eclipse.collections.api.RichIterable.collectShort, org.eclipse.collections.api.collection.ImmutableCollection.collectShort.

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

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

ShortIterable shorts =
    people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());
Annotations
@Override
collectWithback to summary
public <P, V> ImmutableSet<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.collectWith, org.eclipse.collections.api.RichIterable.collectWith, org.eclipse.collections.api.collection.ImmutableCollection.collectWith.

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

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

Example using a Java 8 lambda expression:

RichIterable<Integer> integers =
    Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
Annotations
@Override
differenceback to summary
public ImmutableSet<T> difference(SetIterable<? extends T> subtrahendSet)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.difference, org.eclipse.collections.api.set.SetIterable.difference.

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

Returns the set of all members of this that are not members of subtrahendSet. The difference of [1, 2, 3] and [2, 3, 4] is [1].

Annotations
@Override
flatCollectback to summary
public <V> ImmutableSet<V> flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.flatCollect, org.eclipse.collections.api.RichIterable.flatCollect, org.eclipse.collections.api.collection.ImmutableCollection.flatCollect.

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

flatCollect is a special case of collect(Function). With collect, when the Function returns a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection instead. This method is commonly called flatMap.

Consider the following example where we have a Person class, and each Person has a list of Address objects. Take the following Function:

Function<Person, List<Address>> addressFunction = Person::getAddresses;
RichIterable<Person> people = ...;
Using collect returns a collection of collections of addresses.
RichIterable<List<Address>> addresses = people.collect(addressFunction);
Using flatCollect returns a single flattened list of addresses.
RichIterable<Address> addresses = people.flatCollect(addressFunction);
Annotations
@Override
flatCollectWithback to summary
public default <P, V> ImmutableSet<V> flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.set.UnsortedSetIterable.flatCollectWith, org.eclipse.collections.api.RichIterable.flatCollectWith, org.eclipse.collections.api.collection.ImmutableCollection.flatCollectWith.

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

Same as flatCollect, only with a Function2 that is passed an extra parameter.

Annotations
@Override
Since
9.2
groupByback to summary
public <V> ImmutableSetMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupBy, org.eclipse.collections.api.set.ImmutableSetIterable.groupBy.

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

For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.

Example using a Java 8 method reference:

Multimap<String, Person> peopleByLastName =
    people.groupBy(Person::getLastName);
Annotations
@Override
groupByEachback to summary
public <V> ImmutableSetMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupByEach, org.eclipse.collections.api.set.ImmutableSetIterable.groupByEach.

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

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

Annotations
@Override
intersectback to summary
public ImmutableSet<T> intersect(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.intersect, org.eclipse.collections.api.set.SetIterable.intersect.

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

Returns the set of all objects that are members of both this and set. The intersection of [1, 2, 3] and [2, 3, 4] is the set [2, 3]. The output will contain instances from the smaller of the two sets (this or set) based on the size. If the sizes are equal, the output will contain instances from this.

Note

If you need to ensure that the memory references from this are preserved in the resulting set, consider using this.select(that::contains) instead.

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

Redeclares 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
newWithAllback to summary
public ImmutableSet<T> newWithAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.ImmutableCollection.newWithAll.

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

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

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

Redeclares 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
newWithoutAllback to summary
public ImmutableSet<T> newWithoutAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.ImmutableCollection.newWithoutAll.

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

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

Annotations
@Override
partitionback to summary
public PartitionImmutableSet<T> partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.partition, org.eclipse.collections.api.set.ImmutableSetIterable.partition.

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

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

Example using a Java 8 lambda expression:

PartitionIterable<Person> newYorkersAndNonNewYorkers =
    people.partition(person -> person.getAddress().getState().getName().equals("New York"));
Annotations
@Override
partitionWithback to summary
public <P> PartitionImmutableSet<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.partitionWith, org.eclipse.collections.api.set.ImmutableSetIterable.partitionWith.

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

Filters a collection into a PartitionIterable based on the evaluation of the predicate.

Example using a Java 8 lambda expression:

PartitionIterable<Person> newYorkersAndNonNewYorkers =
    people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
Annotations
@Override
powerSetback to summary
public ImmutableSet<UnsortedSetIterable<T>> powerSet()

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.powerSet.

Doc from org.eclipse.collections.api.set.UnsortedSetIterable.powerSet.

Returns the set whose members are all possible subsets of this. For example, the powerset of [1, 2] is [[], [1], [2], [1, 2]].

Annotations
@Override
rejectback to summary
public ImmutableSet<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.reject, org.eclipse.collections.api.set.ImmutableSetIterable.reject.

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

Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.reject(person -> person.person.getLastName().equals("Smith"));
Annotations
@Override
rejectWithback to summary
public <P> ImmutableSet<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.rejectWith, org.eclipse.collections.api.set.ImmutableSetIterable.rejectWith.

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

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
Annotations
@Override
selectback to summary
public ImmutableSet<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.select, org.eclipse.collections.api.set.ImmutableSetIterable.select.

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

Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.select(person -> person.getAddress().getCity().equals("London"));
Annotations
@Override
selectInstancesOfback to summary
public <S> ImmutableSet<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectInstancesOf, org.eclipse.collections.api.set.ImmutableSetIterable.selectInstancesOf.

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

Returns all elements of the source collection that are instances of the Class clazz.

RichIterable<Integer> integers =
    List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
Annotations
@Override
selectWithback to summary
public <P> ImmutableSet<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectWith, org.eclipse.collections.api.set.ImmutableSetIterable.selectWith.

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

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
Annotations
@Override
symmetricDifferenceback to summary
public ImmutableSet<T> symmetricDifference(SetIterable<? extends T> setB)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.symmetricDifference, org.eclipse.collections.api.set.SetIterable.symmetricDifference.

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

Returns the set of all objects that are a member of exactly one of this and setB (elements which are in one of the sets, but not in both). For instance, for the sets [1, 2, 3] and [2, 3, 4], the symmetric difference set is [1, 4] . It is the set difference of the union and the intersection.

Annotations
@Override
tapback to summary
public ImmutableSet<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.tap, org.eclipse.collections.api.set.ImmutableSetIterable.tap.

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

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
toImmutableSetback to summary
public default ImmutableSet<T> toImmutableSet()

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

Overrides toImmutableSet in RichIterable to return this.

Annotations
@Override
Since
11.0
unionback to summary
public ImmutableSet<T> union(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.union, org.eclipse.collections.api.set.SetIterable.union.

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

Returns the set of all objects that are a member of this or set or both. The union of [1, 2, 3] and [2, 3, 4] is the set [1, 2, 3, 4]. If equal elements appear in both sets, then the output will contain the copy from this.

Annotations
@Override
zipback to summary
public <S> ImmutableSet<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.zip, org.eclipse.collections.api.RichIterable.zip, org.eclipse.collections.api.collection.ImmutableCollection.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
@Override
@Deprecated
zipWithIndexback to summary
public ImmutableSet<Pair<T, Integer>> zipWithIndex()

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.zipWithIndex, org.eclipse.collections.api.set.ImmutableSetIterable.zipWithIndex.

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

Deprecated

in 6.0. Use OrderedIterable#zipWithIndex() instead.

Zips this RichIterable with its indices.

Annotations
@Override
@Deprecated