Top Constructors Methods
org.eclipse.collections.impl.set.mutable

public abstract Class AbstractMutableSet<T>

extends AbstractMutableCollection<T>
implements MutableSet<T>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.set.MutableSet, java.lang.Cloneable, org.eclipse.collections.api.set.MutableSetIterable, java.util.Set, java.util.Collection, java.lang.Iterable, org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, org.eclipse.collections.api.set.SetIterable, org.eclipse.collections.api.set.UnsortedSetIterable
Known Direct Subclasses
org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableBooleanSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableByteSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableCharSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableDoubleSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableFloatSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableIntSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableLongSet, org.eclipse.collections.impl.set.mutable.primitive.BoxedMutableShortSet, org.eclipse.collections.impl.set.fixed.AbstractMemoryEfficientMutableSet
Imports
java.util.Set, org.eclipse.collections.api.LazyIterable, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.factory.Sets, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.set.PartitionMutableSet, org.eclipse.collections.api.set.ImmutableSet, .MutableSet, .SetIterable, .UnsortedSetIterable, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.block.procedure.PartitionPredicate2Procedure, .PartitionProcedure, .SelectInstancesOfProcedure, org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection, org.eclipse.collections.impl.multimap.set.UnifiedSetMultimap, org.eclipse.collections.impl.partition.set.PartitionUnifiedSet, org.eclipse.collections.impl.utility.internal.SetIterables, .SetIterate

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public MutableSet<T>
public MutableSet<T>
public <B> LazyIterable<Pair<T, B>>
cartesianProduct(SetIterable<B> set)

Implements org.eclipse.collections.api.set.SetIterable.cartesianProduct.

Returns the set whose members are all possible ordered pairs (a, b) where a is a member of this and b is a member of set.

public MutableSet<T>
clone()

Overrides java.lang.Object.clone.

Implements org.eclipse.collections.api.set.MutableSet.clone.

Creates and returns a copy of this object.

public <V> MutableSet<V>
collect(Function<? super T, ? extends V> function)

Implements org.eclipse.collections.api.set.MutableSet.collect, org.eclipse.collections.api.collection.MutableCollection.collect, 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.

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

Implements org.eclipse.collections.api.set.MutableSet.collectIf, org.eclipse.collections.api.collection.MutableCollection.collectIf, 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.

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

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

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

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

Implements org.eclipse.collections.api.set.MutableSet.difference.

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

public <R extends Set<T>> R
differenceInto(SetIterable<? extends T> subtrahendSet, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.differenceInto.

Same as difference(SetIterable) but adds all the objects to targetSet and returns it.

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

Implements org.eclipse.collections.api.set.MutableSet.groupBy, org.eclipse.collections.api.collection.MutableCollection.groupBy, 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.

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

Implements org.eclipse.collections.api.set.MutableSet.groupByEach, org.eclipse.collections.api.collection.MutableCollection.groupByEach, 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.

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

Implements org.eclipse.collections.api.set.MutableSet.intersect.

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

public <R extends Set<T>> R
intersectInto(SetIterable<? extends T> set, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.intersectInto.

Same as intersect(SetIterable) but adds all the objects to targetSet and returns it.

public boolean
isProperSubsetOf(SetIterable<? extends T> candidateSuperset)

Implements org.eclipse.collections.api.set.SetIterable.isProperSubsetOf.

Returns true if all the members of this are also members of candidateSuperset and the two sets are not equal.

public boolean
isSubsetOf(SetIterable<? extends T> candidateSuperset)

Implements org.eclipse.collections.api.set.SetIterable.isSubsetOf.

Returns true if all the members of this are also members of candidateSuperset.

public MutableSet<T>
protected <K> MutableSet<K>
public PartitionMutableSet<T>
partition(Predicate<? super T> predicate)

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

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

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

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

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

public MutableSet<UnsortedSetIterable<T>>
powerSet()

Implements org.eclipse.collections.api.set.MutableSet.powerSet.

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

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

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

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

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

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

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

public boolean
public MutableSet<T>
select(Predicate<? super T> predicate)

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

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

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

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

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

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

Implements org.eclipse.collections.api.set.MutableSet.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 <R extends Set<T>> R
symmetricDifferenceInto(SetIterable<? extends T> set, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.symmetricDifferenceInto.

Same as symmetricDifference(SetIterable) but adds all the objects to targetSet and returns it.

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

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

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

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

Implements org.eclipse.collections.api.set.MutableSet.union.

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

public <R extends Set<T>> R
unionInto(SetIterable<? extends T> set, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.unionInto.

Same as union(SetIterable) but adds all the objects to targetSet and returns it.

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

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 MutableSet<Pair<T, Integer>>
Inherited from org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection:
addaddAlladdAllIterablechunkcountBycountByEachcountByWithgroupByUniqueKeyinjectIntoWithreduceremoveremoveAllremoveIfremoveIfWithretainAllretainAllIterableselectAndRejectWithsumByDoublesumByFloatsumByIntsumByLong

Constructor Detail

AbstractMutableSetback to summary
public AbstractMutableSet()

Method Detail

asSynchronizedback to summary
public MutableSet<T> asSynchronized()

Implements org.eclipse.collections.api.set.MutableSet.asSynchronized, org.eclipse.collections.api.collection.MutableCollection.asSynchronized.

Doc from org.eclipse.collections.api.collection.MutableCollection.asSynchronized.

Returns a synchronized wrapper backed by this collection. This is the equivalent of using Collections.synchronizedCollection(this) only with a return type that supports the full iteration protocols available on MutableCollection. The preferred way of iterating over a synchronized collection is to use the internal iteration methods which are properly synchronized internally.

 MutableCollection synchedCollection = collection.asSynchronized();
    ...
 synchedCollection.forEach(each -> ... );
 synchedCollection.select(each -> ... );
 synchedCollection.collect(each -> ... );
If you want to iterate using an imperative style, you must protect external iterators using a synchronized block. This includes explicit iterators as well as JDK 5 style for loops.

Annotations
@Override
asUnmodifiableback to summary
public MutableSet<T> asUnmodifiable()

Implements org.eclipse.collections.api.set.MutableSet.asUnmodifiable, org.eclipse.collections.api.collection.MutableCollection.asUnmodifiable.

Doc from org.eclipse.collections.api.set.MutableSet.asUnmodifiable.

Returns an unmodifiable view of the set.

Annotations
@Override
cartesianProductback to summary
public <B> LazyIterable<Pair<T, B>> cartesianProduct(SetIterable<B> set)

Implements org.eclipse.collections.api.set.SetIterable.cartesianProduct.

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

Returns the set whose members are all possible ordered pairs (a, b) where a is a member of this and b is a member of set.

Annotations
@Override
cloneback to summary
public MutableSet<T> clone()

Overrides java.lang.Object.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
collectback to summary
public <V> MutableSet<V> collect(Function<? super T, ? extends V> function)

Implements org.eclipse.collections.api.set.MutableSet.collect, org.eclipse.collections.api.collection.MutableCollection.collect, org.eclipse.collections.api.RichIterable.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
collectIfback to summary
public <V> MutableSet<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Implements org.eclipse.collections.api.set.MutableSet.collectIf, org.eclipse.collections.api.collection.MutableCollection.collectIf, org.eclipse.collections.api.RichIterable.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
collectWithback to summary
public <P, V> MutableSet<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Implements org.eclipse.collections.api.set.MutableSet.collectWith, org.eclipse.collections.api.collection.MutableCollection.collectWith, org.eclipse.collections.api.RichIterable.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 MutableSet<T> difference(SetIterable<? extends T> subtrahendSet)

Implements org.eclipse.collections.api.set.MutableSet.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
differenceIntoback to summary
public <R extends Set<T>> R differenceInto(SetIterable<? extends T> subtrahendSet, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.differenceInto.

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

Same as difference(SetIterable) but adds all the objects to targetSet and returns it.

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

Implements org.eclipse.collections.api.set.MutableSet.flatCollect, org.eclipse.collections.api.collection.MutableCollection.flatCollect, org.eclipse.collections.api.RichIterable.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
groupByback to summary
public <V> UnifiedSetMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Implements org.eclipse.collections.api.set.MutableSet.groupBy, org.eclipse.collections.api.collection.MutableCollection.groupBy, org.eclipse.collections.api.RichIterable.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> UnifiedSetMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Implements org.eclipse.collections.api.set.MutableSet.groupByEach, org.eclipse.collections.api.collection.MutableCollection.groupByEach, org.eclipse.collections.api.RichIterable.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 MutableSet<T> intersect(SetIterable<? extends T> set)

Implements org.eclipse.collections.api.set.MutableSet.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
intersectIntoback to summary
public <R extends Set<T>> R intersectInto(SetIterable<? extends T> set, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.intersectInto.

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

Same as intersect(SetIterable) but adds all the objects to targetSet and returns it.

Annotations
@Override
isProperSubsetOfback to summary
public boolean isProperSubsetOf(SetIterable<? extends T> candidateSuperset)

Implements org.eclipse.collections.api.set.SetIterable.isProperSubsetOf.

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

Returns true if all the members of this are also members of candidateSuperset and the two sets are not equal. For example, [1, 2] is a proper subset of [1, 2, 3], but [1, 2, 3] is not.

Annotations
@Override
isSubsetOfback to summary
public boolean isSubsetOf(SetIterable<? extends T> candidateSuperset)

Implements org.eclipse.collections.api.set.SetIterable.isSubsetOf.

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

Returns true if all the members of this are also members of candidateSuperset. For example, [1, 2] is a subset of [1, 2, 3], but [1, 4] is not.

Annotations
@Override
newEmptyback to summary
public MutableSet<T> newEmpty()

Implements org.eclipse.collections.api.set.MutableSet.newEmpty, org.eclipse.collections.api.collection.MutableCollection.newEmpty.

Doc from org.eclipse.collections.api.collection.MutableCollection.newEmpty.

Creates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.

Annotations
@Override
newEmptySameSizeback to summary
protected <K> MutableSet<K> newEmptySameSize()
partitionback to summary
public PartitionMutableSet<T> partition(Predicate<? super T> predicate)

Implements org.eclipse.collections.api.set.MutableSet.partition, org.eclipse.collections.api.collection.MutableCollection.partition, org.eclipse.collections.api.RichIterable.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> PartitionMutableSet<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Implements org.eclipse.collections.api.set.MutableSet.partitionWith, org.eclipse.collections.api.collection.MutableCollection.partitionWith, org.eclipse.collections.api.RichIterable.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 MutableSet<UnsortedSetIterable<T>> powerSet()

Implements org.eclipse.collections.api.set.MutableSet.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 MutableSet<T> reject(Predicate<? super T> predicate)

Implements org.eclipse.collections.api.set.MutableSet.reject, org.eclipse.collections.api.collection.MutableCollection.reject, org.eclipse.collections.api.RichIterable.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> MutableSet<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Implements org.eclipse.collections.api.set.MutableSet.rejectWith, org.eclipse.collections.api.collection.MutableCollection.rejectWith, org.eclipse.collections.api.RichIterable.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
removeAllIterableback to summary
public boolean removeAllIterable(Iterable<?> iterable)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection.removeAllIterable.

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

Annotations
@Override
selectback to summary
public MutableSet<T> select(Predicate<? super T> predicate)

Implements org.eclipse.collections.api.set.MutableSet.select, org.eclipse.collections.api.collection.MutableCollection.select, org.eclipse.collections.api.RichIterable.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> MutableSet<S> selectInstancesOf(Class<S> clazz)

Implements org.eclipse.collections.api.set.MutableSet.selectInstancesOf, org.eclipse.collections.api.collection.MutableCollection.selectInstancesOf, org.eclipse.collections.api.RichIterable.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> MutableSet<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Implements org.eclipse.collections.api.set.MutableSet.selectWith, org.eclipse.collections.api.collection.MutableCollection.selectWith, org.eclipse.collections.api.RichIterable.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 MutableSet<T> symmetricDifference(SetIterable<? extends T> setB)

Implements org.eclipse.collections.api.set.MutableSet.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
symmetricDifferenceIntoback to summary
public <R extends Set<T>> R symmetricDifferenceInto(SetIterable<? extends T> set, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.symmetricDifferenceInto.

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

Same as symmetricDifference(SetIterable) but adds all the objects to targetSet and returns it.

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

Implements org.eclipse.collections.api.set.MutableSet.tap, org.eclipse.collections.api.collection.MutableCollection.tap, org.eclipse.collections.api.RichIterable.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
toImmutableback to summary
public ImmutableSet<T> toImmutable()

Implements org.eclipse.collections.api.set.MutableSet.toImmutable, org.eclipse.collections.api.collection.MutableCollection.toImmutable.

Doc from org.eclipse.collections.api.set.MutableSet.toImmutable.

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

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

Implements org.eclipse.collections.api.set.MutableSet.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
unionIntoback to summary
public <R extends Set<T>> R unionInto(SetIterable<? extends T> set, R targetSet)

Implements org.eclipse.collections.api.set.SetIterable.unionInto.

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

Same as union(SetIterable) but adds all the objects to targetSet and returns it.

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

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
@Override
@Deprecated
zipWithIndexback to summary
public MutableSet<Pair<T, Integer>> 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
@Override
@Deprecated