Top Description Fields Constructors Methods
org.eclipse.collections.impl.factory

public final Class Sets

extends Object
Class Inheritance
Annotations
@SuppressWarnings:ConstantNamingConvention
Imports
java.util.Arrays, .Collection, .Comparator, .Set, .SortedSet, .TreeSet, org.eclipse.collections.api.LazyIterable, org.eclipse.collections.api.block.function.Function2, org.eclipse.collections.api.block.predicate.Predicate, org.eclipse.collections.api.block.procedure.Procedure2, org.eclipse.collections.api.factory.set.FixedSizeSetFactory, .ImmutableSetFactory, .MultiReaderSetFactory, .MutableSetFactory, org.eclipse.collections.api.set.MutableSet, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.block.factory.Comparators, org.eclipse.collections.impl.set.fixed.FixedSizeSetFactoryImpl, org.eclipse.collections.impl.set.immutable.ImmutableSetFactoryImpl, org.eclipse.collections.impl.set.mutable.MultiReaderMutableSetFactory, .MutableSetFactoryImpl, .SetAdapter, .UnifiedSet, org.eclipse.collections.impl.tuple.Tuples, org.eclipse.collections.impl.utility.ArrayIterate, .Iterate, .LazyIterate

Set algebra operations are available in this class as static utility.

Most operations are non-destructive, i.e. no input sets are modified during execution. The exception is operations ending in "Into." These accept the target collection of the final calculation as the first parameter.

Some effort is made to return a SortedSet if any input set is sorted, but this is not guaranteed (e.g., this will not be the case for collections proxied by Hibernate). When in doubt, specify the target collection explicitly with the "Into" version. This class should be used to create instances of MutableSet, ImmutableSet and FixedSizeSet

Mutable Examples:

MutableSet<String> emptySet = Sets.mutable.empty();
MutableSet<String> setWith = Sets.mutable.with("a", "b", "c");
MutableSet<String> setOf = Sets.mutable.of("a", "b", "c");
Immutable Examples:
ImmutableSet<String> emptySet = Sets.immutable.empty();
ImmutableSet<String> setWith = Sets.immutable.with("a", "b", "c");
ImmutableSet<String> setOf = Sets.immutable.of("a", "b", "c");
FixedSize Examples:
FixedSizeSet<String> emptySet = Sets.fixedSize.empty();
FixedSizeSet<String> setWith = Sets.fixedSize.with("a", "b", "c");
FixedSizeSet<String> setOf = Sets.fixedSize.of("a", "b", "c");

Field Summary

Modifier and TypeField and Description
public static final FixedSizeSetFactory
private static final Predicate<Set<?>>
public static final ImmutableSetFactory
private static final Predicate<Set<?>>
public static final MultiReaderSetFactory
public static final MutableSetFactory

Constructor Summary

AccessConstructor and Description
private
Sets()

Method Summary

Modifier and TypeMethod and Description
public static <T> MutableSet<T>
adapt(Set<T> set)

private static <E, R extends Set<E>> Procedure2<Set<? extends E>, R>
public static <A, B> LazyIterable<Pair<A, B>>
cartesianProduct(Set<A> set1, Set<B> set2)

public static <A, B, C> LazyIterable<C>
cartesianProduct(Set<A> set1, Set<B> set2, Function2<? super A, ? super B, ? extends C> function)

public static <E> MutableSet<E>
difference(Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)

public static <E> MutableSet<E>
differenceAll(Set<? extends E>... sets)

public static <E, R extends Set<E>> R
differenceAllInto(R targetSet, Set<? extends E>... sets)

public static <E, R extends Set<E>> R
differenceInto(R targetSet, Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)

private static <E> Comparator<? super E>
extractComparator(Set<? extends E>... sets)

private static <E, R extends Set<E>> R
fillSet(R targetSet, Procedure2<Set<? extends E>, R> procedure, Set<? extends E>... sets)

public static <E> MutableSet<E>
intersect(Set<? extends E> setA, Set<? extends E> setB)

public static <E> MutableSet<E>
intersectAll(Set<? extends E>... sets)

public static <E, R extends Set<E>> R
intersectAllInto(R targetSet, Set<? extends E>... sets)

public static <E, R extends Set<E>> R
intersectInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)

public static <E> boolean
isProperSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)

public static <E> boolean
isSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)

private static <E> MutableSet<E>
newSet(Set<? extends E>... sets)

public static <T> MutableSet<MutableSet<T>>
powerSet(Set<T> set)

private static <E, R extends Set<E>> Procedure2<Set<? extends E>, R>
private static <E, R extends Set<E>> Procedure2<Set<? extends E>, R>
public static <E> MutableSet<E>
symmetricDifference(Set<? extends E> setA, Set<? extends E> setB)

public static <E, R extends Set<E>> R
symmetricDifferenceInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)

public static <E> MutableSet<E>
union(Set<? extends E> setA, Set<? extends E> setB)

public static <E> MutableSet<E>
unionAll(Set<? extends E>... sets)

public static <E, R extends Set<E>> R
unionAllInto(R targetSet, Set<? extends E>... sets)

public static <E, R extends Set<E>> R
unionInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fixedSizeback to summary
public static final FixedSizeSetFactory fixedSize
HAS_NON_NULL_COMPARATORback to summary
private static final Predicate<Set<?>> HAS_NON_NULL_COMPARATOR
immutableback to summary
public static final ImmutableSetFactory immutable
INSTANCE_OF_SORTED_SET_PREDICATEback to summary
private static final Predicate<Set<?>> INSTANCE_OF_SORTED_SET_PREDICATE
multiReaderback to summary
public static final MultiReaderSetFactory multiReader
mutableback to summary
public static final MutableSetFactory mutable

Constructor Detail

Setsback to summary
private Sets()

Method Detail

adaptback to summary
public static <T> MutableSet<T> adapt(Set<T> set)
Since
9.0.
addAllProcedureback to summary
private static <E, R extends Set<E>> Procedure2<Set<? extends E>, R> addAllProcedure()
cartesianProductback to summary
public static <A, B> LazyIterable<Pair<A, B>> cartesianProduct(Set<A> set1, Set<B> set2)
cartesianProductback to summary
public static <A, B, C> LazyIterable<C> cartesianProduct(Set<A> set1, Set<B> set2, Function2<? super A, ? super B, ? extends C> function)
differenceback to summary
public static <E> MutableSet<E> difference(Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)
differenceAllback to summary
public static <E> MutableSet<E> differenceAll(Set<? extends E>... sets)
differenceAllIntoback to summary
public static <E, R extends Set<E>> R differenceAllInto(R targetSet, Set<? extends E>... sets)
differenceIntoback to summary
public static <E, R extends Set<E>> R differenceInto(R targetSet, Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)
extractComparatorback to summary
private static <E> Comparator<? super E> extractComparator(Set<? extends E>... sets)
fillSetback to summary
private static <E, R extends Set<E>> R fillSet(R targetSet, Procedure2<Set<? extends E>, R> procedure, Set<? extends E>... sets)
intersectback to summary
public static <E> MutableSet<E> intersect(Set<? extends E> setA, Set<? extends E> setB)
intersectAllback to summary
public static <E> MutableSet<E> intersectAll(Set<? extends E>... sets)
intersectAllIntoback to summary
public static <E, R extends Set<E>> R intersectAllInto(R targetSet, Set<? extends E>... sets)
intersectIntoback to summary
public static <E, R extends Set<E>> R intersectInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)
isProperSubsetOfback to summary
public static <E> boolean isProperSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)
isSubsetOfback to summary
public static <E> boolean isSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)
newSetback to summary
private static <E> MutableSet<E> newSet(Set<? extends E>... sets)
powerSetback to summary
public static <T> MutableSet<MutableSet<T>> powerSet(Set<T> set)
removeAllProcedureback to summary
private static <E, R extends Set<E>> Procedure2<Set<? extends E>, R> removeAllProcedure()
retainAllProcedureback to summary
private static <E, R extends Set<E>> Procedure2<Set<? extends E>, R> retainAllProcedure()
symmetricDifferenceback to summary
public static <E> MutableSet<E> symmetricDifference(Set<? extends E> setA, Set<? extends E> setB)
symmetricDifferenceIntoback to summary
public static <E, R extends Set<E>> R symmetricDifferenceInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)
unionback to summary
public static <E> MutableSet<E> union(Set<? extends E> setA, Set<? extends E> setB)
unionAllback to summary
public static <E> MutableSet<E> unionAll(Set<? extends E>... sets)
unionAllIntoback to summary
public static <E, R extends Set<E>> R unionAllInto(R targetSet, Set<? extends E>... sets)
unionIntoback to summary
public static <E, R extends Set<E>> R unionInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)