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

public Interface SetIterable<T>

extends RichIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.set.UnsortedSetIterable, org.eclipse.collections.api.set.sorted.SortedSetIterable, org.eclipse.collections.api.set.ImmutableSetIterable, org.eclipse.collections.api.set.MutableSetIterable
Imports
java.util.Set, java.util.concurrent.ExecutorService, org.eclipse.collections.api.LazyIterable, .RichIterable, org.eclipse.collections.api.annotation.Beta, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.set.PartitionSet, org.eclipse.collections.api.tuple.Pair

A Read-only Set api, with the minor exception inherited from java.lang.Iterable (iterable.iterator().remove()).

Method Summary

Modifier and TypeMethod and Description
public ParallelSetIterable<T>
asParallel(ExecutorService executorService, int batchSize)

Returns a parallel iterable of this SetIterable.

public <B> LazyIterable<Pair<T, B>>
cartesianProduct(SetIterable<B> set)

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 SetIterable<T>
difference(SetIterable<? extends T> subtrahendSet)

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)

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

public boolean
equals(Object o)

Follows the same general contract as Set#equals(Object).

public int
hashCode()

Follows the same general contract as Set#hashCode().

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

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)

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

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

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)

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

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

Redeclares org.eclipse.collections.api.RichIterable.partition.

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

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

Redeclares org.eclipse.collections.api.RichIterable.partitionWith.

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

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

Redeclares org.eclipse.collections.api.RichIterable.reject.

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

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

Redeclares org.eclipse.collections.api.RichIterable.rejectWith.

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

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

Redeclares org.eclipse.collections.api.RichIterable.select.

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

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

Redeclares org.eclipse.collections.api.RichIterable.selectInstancesOf.

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

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

Redeclares org.eclipse.collections.api.RichIterable.selectWith.

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

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

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)

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

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

Redeclares org.eclipse.collections.api.RichIterable.tap.

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

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

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)

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

public SetIterable<Pair<T, Integer>>
zipWithIndex()

Redeclares org.eclipse.collections.api.RichIterable.zipWithIndex.

Deprecated in 6.0. Use OrderedIterable#zipWithIndex() instead.

Zips this RichIterable with its indices.

Inherited from org.eclipse.collections.api.RichIterable:
aggregateByaggregateByaggregateInPlaceByallSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringappendStringasLazychunkcollectcollectcollectBooleancollectBooleancollectBytecollectBytecollectCharcollectCharcollectDoublecollectDoublecollectFloatcollectFloatcollectIfcollectIfcollectIntcollectIntcollectLongcollectLongcollectShortcollectShortcollectWithcollectWithcontainscontainsAllcontainsAllArgumentscontainsAllIterablecontainsAnycontainsAnyIterablecontainsBycontainsNonecontainsNoneIterablecountcountBycountBycountByEachcountByEachcountByWithcountByWithcountWithdetectdetectIfNonedetectOptionaldetectWithdetectWithIfNonedetectWithOptionaleachflatCollectflatCollectflatCollectBooleanflatCollectByteflatCollectCharflatCollectDoubleflatCollectFloatflatCollectIntflatCollectLongflatCollectShortflatCollectWithflatCollectWithforEachgetAnygetFirstgetLastgetOnlygroupBygroupBygroupByAndCollectgroupByEachgroupByEachgroupByUniqueKeygroupByUniqueKeyinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoDoubleinjectIntoFloatinjectIntoIntinjectIntoLongintoisEmptymakeStringmakeStringmakeStringmakeStringmaxmaxmaxBymaxByOptionalmaxOptionalmaxOptionalminminminByminByOptionalminOptionalminOptionalnoneSatisfynoneSatisfyWithnotEmptyreducereduceByreduceByreduceInPlacereduceInPlacerejectrejectWithselectselectWithsizesumByDoublesumByFloatsumByIntsumByLongsummarizeDoublesummarizeFloatsummarizeIntsummarizeLongsumOfDoublesumOfFloatsumOfIntsumOfLongtoArraytoArraytoBagtoBiMaptoImmutableBagtoImmutableBiMaptoImmutableListtoImmutableMaptoImmutableSettoImmutableSortedBagtoImmutableSortedBagtoImmutableSortedBagBytoImmutableSortedListtoImmutableSortedListtoImmutableSortedListBytoImmutableSortedSettoImmutableSortedSettoImmutableSortedSetBytoListtoMaptoMaptoSettoSortedBagtoSortedBagtoSortedBagBytoSortedListtoSortedListtoSortedListBytoSortedMaptoSortedMaptoSortedMapBytoSortedSettoSortedSettoSortedSetBytoStringzipzipzipWithIndex

Method Detail

asParallelback to summary
public ParallelSetIterable<T> asParallel(ExecutorService executorService, int batchSize)

Returns a parallel iterable of this SetIterable.

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

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.

differenceback to summary
public SetIterable<T> difference(SetIterable<? extends T> subtrahendSet)

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

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

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

equalsback to summary
public boolean equals(Object o)

Follows the same general contract as Set#equals(Object).

Annotations
@Override
hashCodeback to summary
public int hashCode()

Follows the same general contract as Set#hashCode().

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

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.

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

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

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

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.

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

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.

partitionback to summary
public PartitionSet<T> partition(Predicate<? super T> predicate)

Redeclares 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> PartitionSet<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares 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
rejectback to summary
public SetIterable<T> reject(Predicate<? super T> predicate)

Redeclares 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> SetIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares 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
selectback to summary
public SetIterable<T> select(Predicate<? super T> predicate)

Redeclares 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> SetIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares 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> SetIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares 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 SetIterable<T> symmetricDifference(SetIterable<? extends T> setB)

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.

symmetricDifferenceIntoback to summary
public <R extends Set<T>> R symmetricDifferenceInto(SetIterable<? extends T> set, R targetSet)

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

tapback to summary
public SetIterable<T> tap(Procedure<? super T> procedure)

Redeclares 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 ImmutableSetIterable<T> toImmutable()
unionback to summary
public SetIterable<T> union(SetIterable<? extends T> set)

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.

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

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

zipWithIndexback to summary
public SetIterable<Pair<T, Integer>> zipWithIndex()

Redeclares 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