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

public Interface MutableSet<T>

extends UnsortedSetIterable<T>, MutableSetIterable<T>, Cloneable
Known Direct Subinterfaces
org.eclipse.collections.api.set.FixedSizeSet, org.eclipse.collections.api.set.MultiReaderSet
Imports
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.factory.primitive.BooleanSets, .ByteSets, .CharSets, .DoubleSets, .FloatSets, .IntSets, .LongSets, .ShortSets, org.eclipse.collections.api.multimap.set.MutableSetMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.set.PartitionMutableSet, org.eclipse.collections.api.set.primitive.MutableBooleanSet, .MutableByteSet, .MutableCharSet, .MutableDoubleSet, .MutableFloatSet, .MutableIntSet, .MutableLongSet, .MutableShortSet, org.eclipse.collections.api.tuple.Pair

A MutableSet is an extension java.util.Set which provides methods matching the Smalltalk Collection protocol.

Method Summary

Modifier and TypeMethod and Description
public MutableSet<T>
asSynchronized()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asSynchronized.

Returns a synchronized wrapper backed by this collection.

public MutableSet<T>

Returns:

an unmodifiable view of this set
asUnmodifiable
()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asUnmodifiable.

Returns an unmodifiable view of the set.

public MutableSet<T>
public <V> MutableSet<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.MutableCollection.collect.

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

public default MutableBooleanSet
collectBoolean(BooleanFunction<? super T> booleanFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectBoolean.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectBoolean, 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.

public default MutableByteSet
collectByte(ByteFunction<? super T> byteFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectByte.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectByte, 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.

public default MutableCharSet
collectChar(CharFunction<? super T> charFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectChar.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectChar, 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.

public default MutableDoubleSet
collectDouble(DoubleFunction<? super T> doubleFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectDouble.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectDouble, 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.

public default MutableFloatSet
collectFloat(FloatFunction<? super T> floatFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectFloat.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectFloat, 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.

public <V> MutableSet<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.MutableCollection.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 default MutableIntSet
collectInt(IntFunction<? super T> intFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectInt.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectInt, 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.

public default MutableLongSet
collectLong(LongFunction<? super T> longFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectLong.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectLong, 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.

public default MutableShortSet
collectShort(ShortFunction<? super T> shortFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectShort.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectShort, 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.

public <P, V> MutableSet<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.MutableCollection.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)

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> MutableSet<V>
public default <P, V> MutableSet<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.MutableCollection.flatCollectWith.

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

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

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupBy, org.eclipse.collections.api.set.MutableSetIterable.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> MutableSetMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupByEach, org.eclipse.collections.api.set.MutableSetIterable.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)

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 MutableSet<T>
newEmpty()

Redeclares org.eclipse.collections.api.collection.MutableCollection.newEmpty.

Creates a new empty mutable version of the same collection type.

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

Redeclares org.eclipse.collections.api.set.SetIterable.partition, org.eclipse.collections.api.set.MutableSetIterable.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)

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

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

public MutableSet<UnsortedSetIterable<T>>
powerSet()

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

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

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

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.reject, org.eclipse.collections.api.set.MutableSetIterable.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)

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

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

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

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

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

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

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

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

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

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectWith, org.eclipse.collections.api.set.MutableSetIterable.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)

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 MutableSet<T>
tap(Procedure<? super T> procedure)

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

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

public ImmutableSet<T>
public default ImmutableSet<T>
toImmutableSet()

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

Converts the MutableSet to the default ImmutableSet implementation.

public MutableSet<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 default MutableSet<T>
with(T element)

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

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

public default MutableSet<T>
withAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.set.MutableSetIterable.withAll.

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

public default MutableSet<T>
without(T element)

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

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

public default MutableSet<T>
withoutAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.set.MutableSetIterable.withoutAll.

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

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

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.zip, org.eclipse.collections.api.set.MutableSetIterable.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.api.set.MutableSetIterable:
toArraytoArray
Inherited from org.eclipse.collections.api.set.UnsortedSetIterable:
asParallel

Method Detail

asSynchronizedback to summary
public MutableSet<T> asSynchronized()

Redeclares 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()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asUnmodifiable.

Returns an unmodifiable view of the set.

Returns:MutableSet<T>

an unmodifiable view of this set

Annotations
@Override
cloneback to summary
public MutableSet<T> clone()
collectback to summary
public <V> MutableSet<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.MutableCollection.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 default MutableBooleanSet collectBoolean(BooleanFunction<? super T> booleanFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectBoolean.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectBoolean, org.eclipse.collections.api.RichIterable.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 default MutableByteSet collectByte(ByteFunction<? super T> byteFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectByte.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectByte, org.eclipse.collections.api.RichIterable.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 default MutableCharSet collectChar(CharFunction<? super T> charFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectChar.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectChar, org.eclipse.collections.api.RichIterable.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 default MutableDoubleSet collectDouble(DoubleFunction<? super T> doubleFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectDouble.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectDouble, org.eclipse.collections.api.RichIterable.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 default MutableFloatSet collectFloat(FloatFunction<? super T> floatFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectFloat.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectFloat, org.eclipse.collections.api.RichIterable.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> MutableSet<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.MutableCollection.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 default MutableIntSet collectInt(IntFunction<? super T> intFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectInt.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectInt, org.eclipse.collections.api.RichIterable.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 default MutableLongSet collectLong(LongFunction<? super T> longFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectLong.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectLong, org.eclipse.collections.api.RichIterable.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 default MutableShortSet collectShort(ShortFunction<? super T> shortFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectShort.

Implements org.eclipse.collections.api.set.UnsortedSetIterable.collectShort, org.eclipse.collections.api.RichIterable.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> MutableSet<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.MutableCollection.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)

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> MutableSet<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.MutableCollection.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> MutableSet<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.MutableCollection.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> MutableSetMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupBy, org.eclipse.collections.api.set.MutableSetIterable.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> MutableSetMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.groupByEach, org.eclipse.collections.api.set.MutableSetIterable.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)

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
newEmptyback to summary
public MutableSet<T> newEmpty()

Redeclares 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
partitionback to summary
public PartitionMutableSet<T> partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.partition, org.eclipse.collections.api.set.MutableSetIterable.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)

Redeclares org.eclipse.collections.api.set.SetIterable.partitionWith, org.eclipse.collections.api.set.MutableSetIterable.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()

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 MutableSet<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.reject, org.eclipse.collections.api.set.MutableSetIterable.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)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.rejectWith, org.eclipse.collections.api.set.MutableSetIterable.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 MutableSet<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.select, org.eclipse.collections.api.set.MutableSetIterable.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)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectInstancesOf, org.eclipse.collections.api.set.MutableSetIterable.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)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.selectWith, org.eclipse.collections.api.set.MutableSetIterable.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)

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 MutableSet<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.tap, org.eclipse.collections.api.set.MutableSetIterable.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()

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.toImmutable, org.eclipse.collections.api.set.SetIterable.toImmutable, org.eclipse.collections.api.collection.MutableCollection.toImmutable.

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

Annotations
@Override
toImmutableSetback to summary
public default ImmutableSet<T> toImmutableSet()

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

Converts the MutableSet to the default ImmutableSet implementation.

Annotations
@Override
Since
11.0
unionback to summary
public MutableSet<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
withback to summary
public default MutableSet<T> with(T element)

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

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

This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list = list.with("1");
list = list.with("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by with, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling add on itself.
Annotations
@Override
withAllback to summary
public default MutableSet<T> withAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.set.MutableSetIterable.withAll.

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

This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling addAll on itself.
Annotations
@Override
withoutback to summary
public default MutableSet<T> without(T element)

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

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

This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list = list.without("1");
list = list.without("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by without, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling remove on itself.
Annotations
@Override
withoutAllback to summary
public default MutableSet<T> withoutAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.set.MutableSetIterable.withoutAll.

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

This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling removeAll on itself.
Annotations
@Override
zipback to summary
public <S> MutableSet<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.zip, org.eclipse.collections.api.set.MutableSetIterable.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()

Redeclares org.eclipse.collections.api.set.UnsortedSetIterable.zipWithIndex, org.eclipse.collections.api.set.MutableSetIterable.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