Class Sets
java.lang.Object
org.eclipse.collections.impl.factory.Sets
public final class Sets extends Object
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
Fields Modifier and Type Field Description static FixedSizeSetFactory
fixedSize
static ImmutableSetFactory
immutable
static MultiReaderSetFactory
multiReader
static MutableSetFactory
mutable
-
Method Summary
Modifier and Type Method Description static <T> MutableSet<T>
adapt(Set<T> list)
static <A, B> LazyIterable<Pair<A,B>>
cartesianProduct(Set<A> set1, Set<B> set2)
static <A, B, C> LazyIterable<C>
cartesianProduct(Set<A> set1, Set<B> set2, Function2<? super A,? super B,? extends C> function)
static <E> MutableSet<E>
difference(Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)
static <E> MutableSet<E>
differenceAll(Set<? extends E>... sets)
static <E, R extends Set<E>>
RdifferenceAllInto(R targetSet, Set<? extends E>... sets)
static <E, R extends Set<E>>
RdifferenceInto(R targetSet, Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)
static <E> MutableSet<E>
intersect(Set<? extends E> setA, Set<? extends E> setB)
static <E> MutableSet<E>
intersectAll(Set<? extends E>... sets)
static <E, R extends Set<E>>
RintersectAllInto(R targetSet, Set<? extends E>... sets)
static <E, R extends Set<E>>
RintersectInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)
static <E> boolean
isProperSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)
static <E> boolean
isSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)
static <T> MutableSet<MutableSet<T>>
powerSet(Set<T> set)
static <E> MutableSet<E>
symmetricDifference(Set<? extends E> setA, Set<? extends E> setB)
static <E, R extends Set<E>>
RsymmetricDifferenceInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)
static <E> MutableSet<E>
union(Set<? extends E> setA, Set<? extends E> setB)
static <E> MutableSet<E>
unionAll(Set<? extends E>... sets)
static <E, R extends Set<E>>
RunionAllInto(R targetSet, Set<? extends E>... sets)
static <E, R extends Set<E>>
RunionInto(R targetSet, Set<? extends E> setA, Set<? extends E> setB)
-
Field Details
-
Method Details
-
adapt
- Since:
- 9.0.
-
union
-
unionInto
-
unionAll
-
unionAllInto
-
intersect
-
intersectInto
-
intersectAll
-
intersectAllInto
-
difference
public static <E> MutableSet<E> difference(Set<? extends E> minuendSet, Set<? extends E> subtrahendSet) -
differenceInto
-
differenceAll
-
differenceAllInto
-
symmetricDifference
-
symmetricDifferenceInto
-
isSubsetOf
-
isProperSubsetOf
-
powerSet
-
cartesianProduct
-
cartesianProduct
public static <A, B, C> LazyIterable<C> cartesianProduct(Set<A> set1, Set<B> set2, Function2<? super A,? super B,? extends C> function)
-