public final class Sets extends Object
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");
Modifier and Type | Field | Description |
---|---|---|
static FixedSizeSetFactory |
fixedSize |
|
static ImmutableSetFactory |
immutable |
|
static MultiReaderSetFactory |
multiReader |
|
static MutableSetFactory |
mutable |
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>> |
differenceAllInto(R targetSet,
Set<? extends E>... sets) |
|
static <E,R extends Set<E>> |
differenceInto(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>> |
intersectAllInto(R targetSet,
Set<? extends E>... sets) |
|
static <E,R extends Set<E>> |
intersectInto(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>> |
symmetricDifferenceInto(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>> |
unionAllInto(R targetSet,
Set<? extends E>... sets) |
|
static <E,R extends Set<E>> |
unionInto(R targetSet,
Set<? extends E> setA,
Set<? extends E> setB) |
public static final ImmutableSetFactory immutable
public static final FixedSizeSetFactory fixedSize
public static final MutableSetFactory mutable
public static final MultiReaderSetFactory multiReader
public static <T> MutableSet<T> adapt(Set<T> list)
public static <E> MutableSet<E> union(Set<? extends E> setA, Set<? extends E> setB)
public static <E,R extends Set<E>> R unionInto(R targetSet, 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> MutableSet<E> intersect(Set<? extends E> setA, Set<? extends E> setB)
public static <E,R extends Set<E>> R intersectInto(R targetSet, 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> MutableSet<E> difference(Set<? extends E> minuendSet, Set<? extends E> subtrahendSet)
public static <E,R extends Set<E>> R differenceInto(R targetSet, 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> 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> boolean isSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)
public static <E> boolean isProperSubsetOf(Set<? extends E> candidateSubset, Set<? extends E> candidateSuperset)
public static <T> MutableSet<MutableSet<T>> powerSet(Set<T> set)
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)
Copyright © 2004–2019. All rights reserved.