Top Methods
org.eclipse.collections.api.set

public Interface MutableSetIterable<T>

extends SetIterable<T>, MutableCollection<T>, Set<T>
Known Direct Subinterfaces
org.eclipse.collections.api.set.sorted.MutableSortedSet, org.eclipse.collections.api.set.MutableSet
Imports
java.util.Set, org.eclipse.collections.api.block.function.Function, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.multimap.set.MutableSetIterableMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.set.PartitionMutableSetIterable, org.eclipse.collections.api.tuple.Pair

Since
6.0

Method Summary

Modifier and TypeMethod and Description
public <V> MutableSetIterableMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

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

Redeclares org.eclipse.collections.api.RichIterable.groupByEach, org.eclipse.collections.api.collection.MutableCollection.groupByEach.

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

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

Redeclares org.eclipse.collections.api.set.SetIterable.partition, org.eclipse.collections.api.collection.MutableCollection.partition.

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

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

Redeclares org.eclipse.collections.api.set.SetIterable.partitionWith, org.eclipse.collections.api.collection.MutableCollection.partitionWith.

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

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

Redeclares org.eclipse.collections.api.set.SetIterable.reject, org.eclipse.collections.api.collection.MutableCollection.reject.

Returns a MutableCollection with all elements that evaluate to false for the specified predicate.

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

Redeclares org.eclipse.collections.api.set.SetIterable.rejectWith, org.eclipse.collections.api.collection.MutableCollection.rejectWith.

Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter.

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

Redeclares org.eclipse.collections.api.set.SetIterable.select, org.eclipse.collections.api.collection.MutableCollection.select.

Returns a MutableCollection with all elements that evaluate to true for the specified predicate.

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

Redeclares org.eclipse.collections.api.set.SetIterable.selectInstancesOf, org.eclipse.collections.api.collection.MutableCollection.selectInstancesOf.

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

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

Redeclares org.eclipse.collections.api.set.SetIterable.selectWith, org.eclipse.collections.api.collection.MutableCollection.selectWith.

Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.

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

Redeclares org.eclipse.collections.api.set.SetIterable.tap, org.eclipse.collections.api.collection.MutableCollection.tap.

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

public default Object[]
toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray, org.eclipse.collections.api.collection.MutableCollection.toArray.

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set.

public default <T1> T1[]
toArray(T1[] a)

Overrides default org.eclipse.collections.api.RichIterable.toArray, org.eclipse.collections.api.collection.MutableCollection.toArray.

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

public default MutableSetIterable<T>
with(T element)

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

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

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

Implements 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.

public default MutableSetIterable<T>
without(T element)

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

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

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

Implements 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.

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

Redeclares org.eclipse.collections.api.RichIterable.zip, org.eclipse.collections.api.collection.MutableCollection.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 MutableSetIterable<Pair<T, Integer>>
Inherited from java.util.Set:
addaddAllclearcontainscontainsAllcopyOfequalshashCodeisEmptyiteratorofofofofofofofofofofofofremoveremoveAllretainAllsizespliterator
Inherited from org.eclipse.collections.api.collection.MutableCollection:
addAllIterableaggregateByaggregateInPlaceByasSynchronizedasUnmodifiablecollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcountBycountByEachcountByWithflatCollectflatCollectWithgroupByUniqueKeyinjectIntoWithnewEmptyremoveAllIterableremoveIfremoveIfWithretainAllIterableselectAndRejectWithsumByDoublesumByFloatsumByIntsumByLongtoImmutable
Inherited from org.eclipse.collections.api.set.SetIterable:
asParallelcartesianProductdifferencedifferenceIntoequalshashCodeintersectintersectIntoisProperSubsetOfisSubsetOfsymmetricDifferencesymmetricDifferenceIntotoImmutableunionunionInto

Method Detail

groupByback to summary
public <V> MutableSetIterableMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.groupBy, org.eclipse.collections.api.collection.MutableCollection.groupBy.

Doc from org.eclipse.collections.api.collection.MutableCollection.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);
Co-variant example for MutableCollection:
MutableMultimap<String, Person> peopleByLastName =
    people.groupBy(Person::getLastName);
Annotations
@Override
groupByEachback to summary
public <V> MutableSetIterableMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.groupByEach, org.eclipse.collections.api.collection.MutableCollection.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
partitionback to summary
public PartitionMutableSetIterable<T> partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.partition, org.eclipse.collections.api.collection.MutableCollection.partition.

Doc from org.eclipse.collections.api.collection.MutableCollection.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"));
Co-variant example for MutableCollection:
PartitionMutableCollection<Person> newYorkersAndNonNewYorkers =
    people.partition(person -> person.getAddress().getState().getName().equals("New York"));
Annotations
@Override
partitionWithback to summary
public <P> PartitionMutableSetIterable<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.partitionWith, org.eclipse.collections.api.collection.MutableCollection.partitionWith.

Doc from org.eclipse.collections.api.collection.MutableCollection.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");
Co-variant example for MutableCollection:
PartitionMutableCollection<Person> newYorkersAndNonNewYorkers =
    people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
Annotations
@Override
rejectback to summary
public MutableSetIterable<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.reject, org.eclipse.collections.api.collection.MutableCollection.reject.

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

Returns a MutableCollection with all elements that evaluate to false for the specified predicate.

MutableCollection<Person> notSmiths =
    people.reject(person -> person.person.getLastName().equals("Smith"));
Using the Predicates factory:
MutableCollection<Person> notSmiths = people.reject(Predicates.attributeEqual("lastName", "Smith"));
Annotations
@Override
rejectWithback to summary
public <P> MutableSetIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.rejectWith, org.eclipse.collections.api.collection.MutableCollection.rejectWith.

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

Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter.

e.g.
MutableCollection<Integer> selected =
    integers.rejectWith(Predicates2.equal(), Integer.valueOf(5));
Annotations
@Override
selectback to summary
public MutableSetIterable<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.select, org.eclipse.collections.api.collection.MutableCollection.select.

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

Returns a MutableCollection with all elements that evaluate to true for the specified predicate.

MutableCollection<Integer> livesInLondon =
    people.select(person -> person.getAddress().getCity().equals("London"));
Annotations
@Override
selectInstancesOfback to summary
public <S> MutableSetIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.set.SetIterable.selectInstancesOf, org.eclipse.collections.api.collection.MutableCollection.selectInstancesOf.

Doc from org.eclipse.collections.api.collection.MutableCollection.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);
Co-variant example for MutableCollection:
MutableCollection<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> MutableSetIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.selectWith, org.eclipse.collections.api.collection.MutableCollection.selectWith.

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

Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.

MutableCollection<Integer> fives =
    integers.selectWith(Predicates2.equal(), Integer.valueOf(5));
Annotations
@Override
tapback to summary
public MutableSetIterable<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.set.SetIterable.tap, org.eclipse.collections.api.collection.MutableCollection.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
toArrayback to summary
public default Object[] toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray, org.eclipse.collections.api.collection.MutableCollection.toArray.

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Annotations
@Override
toArrayback to summary
public default <T1> T1[] toArray(T1[] a)

Overrides default org.eclipse.collections.api.RichIterable.toArray, org.eclipse.collections.api.collection.MutableCollection.toArray.

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set.

If this set fits in the specified array with room to spare (i.e., the array has more elements than this set), the element in the array immediately following the end of the set is set to null. (This is useful in determining the length of this set only if the caller knows that this set does not contain any null elements.)

If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a set known to contain only strings. The following code can be used to dump the set into a newly allocated array of String:

    String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Annotations
@Override
withback to summary
public default MutableSetIterable<T> with(T element)

Implements org.eclipse.collections.api.collection.MutableCollection.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 MutableSetIterable<T> withAll(Iterable<? extends T> elements)

Implements org.eclipse.collections.api.collection.MutableCollection.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 MutableSetIterable<T> without(T element)

Implements org.eclipse.collections.api.collection.MutableCollection.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 MutableSetIterable<T> withoutAll(Iterable<? extends T> elements)

Implements org.eclipse.collections.api.collection.MutableCollection.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> MutableCollection<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.RichIterable.zip, org.eclipse.collections.api.collection.MutableCollection.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 MutableSetIterable<Pair<T, Integer>> zipWithIndex()

Redeclares org.eclipse.collections.api.set.SetIterable.zipWithIndex, org.eclipse.collections.api.collection.MutableCollection.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