public interface SetIterable<T> extends RichIterable<T>
Modifier and Type | Method and Description |
---|---|
ParallelSetIterable<T> |
asParallel(ExecutorService executorService,
int batchSize)
Returns a parallel iterable of this SetIterable.
|
<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 . |
SetIterable<T> |
difference(SetIterable<? extends T> subtrahendSet)
Returns the set of all members of
this that are not members of subtrahendSet . |
<R extends Set<T>> |
differenceInto(SetIterable<? extends T> subtrahendSet,
R targetSet)
Same as
difference(SetIterable) but adds all the objects to targetSet and returns it. |
boolean |
equals(Object o)
Follows the same general contract as
Set.equals(Object) . |
int |
hashCode()
Follows the same general contract as
Set.hashCode() . |
SetIterable<T> |
intersect(SetIterable<? extends T> set)
Returns the set of all objects that are members of both
this and set . |
<R extends Set<T>> |
intersectInto(SetIterable<? extends T> set,
R targetSet)
Same as
intersect(SetIterable) but adds all the objects to targetSet and returns it. |
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. |
boolean |
isSubsetOf(SetIterable<? extends T> candidateSuperset)
Returns true if all the members of
this are also members of candidateSuperset . |
PartitionSet<T> |
partition(Predicate<? super T> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
<P> PartitionSet<T> |
partitionWith(Predicate2<? super T,? super P> predicate,
P parameter)
Filters a collection into a PartitionIterable based on the evaluation of the predicate.
|
SetIterable<T> |
reject(Predicate<? super T> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.
|
<P> SetIterable<T> |
rejectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.reject(Predicate) , except with an evaluation parameter for the second generic argument in Predicate2 . |
SetIterable<T> |
select(Predicate<? super T> predicate)
Returns all elements of the source collection that return true when evaluating the predicate.
|
<S> SetIterable<S> |
selectInstancesOf(Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz . |
<P> SetIterable<T> |
selectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.select(Predicate) , except with an evaluation parameter for the second generic argument in Predicate2 . |
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). |
<R extends Set<T>> |
symmetricDifferenceInto(SetIterable<? extends T> set,
R targetSet)
Same as
symmetricDifference(SetIterable) but adds all the objects to targetSet and returns it. |
ImmutableSetIterable<T> |
toImmutable() |
SetIterable<T> |
union(SetIterable<? extends T> set)
Returns the set of all objects that are a member of
this or set or both. |
<R extends Set<T>> |
unionInto(SetIterable<? extends T> set,
R targetSet)
Same as
union(SetIterable) but adds all the objects to targetSet and returns it. |
SetIterable<Pair<T,Integer>> |
zipWithIndex()
Deprecated.
in 6.0. Use
OrderedIterable.zipWithIndex() instead. |
aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collect, collectBoolean, collectBoolean, collectByte, collectByte, collectChar, collectChar, collectDouble, collectDouble, collectFloat, collectFloat, collectIf, collectIf, collectInt, collectInt, collectLong, collectLong, collectShort, collectShort, collectWith, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, flatCollect, getFirst, getLast, groupBy, groupBy, groupByEach, groupByEach, groupByUniqueKey, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, size, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, tap, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zip, zipWithIndex
forEach, forEachWith, forEachWithIndex
forEach, iterator, spliterator
SetIterable<T> union(SetIterable<? extends T> set)
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
.<R extends Set<T>> R unionInto(SetIterable<? extends T> set, R targetSet)
union(SetIterable)
but adds all the objects to targetSet
and returns it.SetIterable<T> intersect(SetIterable<? extends T> set)
this
and set
. The intersection of
[1, 2, 3] and [2, 3, 4] is the set [2, 3]. The output will contain instances from this
, not set
.<R extends Set<T>> R intersectInto(SetIterable<? extends T> set, R targetSet)
intersect(SetIterable)
but adds all the objects to targetSet
and returns it.SetIterable<T> difference(SetIterable<? extends T> subtrahendSet)
this
that are not members of subtrahendSet
. The difference of
[1, 2, 3] and [2, 3, 4] is [1].<R extends Set<T>> R differenceInto(SetIterable<? extends T> subtrahendSet, R targetSet)
difference(SetIterable)
but adds all the objects to targetSet
and returns it.SetIterable<T> symmetricDifference(SetIterable<? extends T> setB)
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.<R extends Set<T>> R symmetricDifferenceInto(SetIterable<? extends T> set, R targetSet)
symmetricDifference(SetIterable)
but adds all the objects to targetSet
and returns it.boolean isSubsetOf(SetIterable<? extends T> candidateSuperset)
this
are also members of candidateSuperset
.
For example, [1, 2] is a subset of [1, 2, 3], but [1, 4] is not.boolean isProperSubsetOf(SetIterable<? extends T> candidateSuperset)
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.<B> LazyIterable<Pair<T,B>> cartesianProduct(SetIterable<B> set)
this
and b is a
member of set
.SetIterable<T> select(Predicate<? super T> predicate)
RichIterable
Example using a Java 8 lambda expression:
RichIterable<Person> selected = people.select(person -> person.getAddress().getCity().equals("London"));
Example using an anonymous inner class:
RichIterable<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getCity().equals("London"); } });
select
in interface RichIterable<T>
<P> SetIterable<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
RichIterable.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));
Example using an anonymous inner class:
RichIterable<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() >= age; } }, Integer.valueOf(18));
selectWith
in interface RichIterable<T>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
RichIterable.select(Predicate)
SetIterable<T> reject(Predicate<? super T> predicate)
RichIterable
Example using a Java 8 lambda expression:
RichIterable<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"));
Example using an anonymous inner class:
RichIterable<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } });
reject
in interface RichIterable<T>
predicate
- a Predicate
to use as the reject criteriaPredicate.accept(Object)
method to evaluate to false<P> SetIterable<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
RichIterable.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));
Example using an anonymous inner class:
MutableList<Person> rejected = people.rejectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() < age; } }, Integer.valueOf(18));
rejectWith
in interface RichIterable<T>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
RichIterable.select(Predicate)
PartitionSet<T> partition(Predicate<? super T> predicate)
RichIterable
Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partition(person -> person.getAddress().getState().getName().equals("New York"));
Example using an anonymous inner class:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partition(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });
partition
in interface RichIterable<T>
<P> PartitionSet<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
Example using a Java 8 lambda expression:
PartitionIterable<Person>> newYorkersAndNonNewYorkers = people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
Example using an anonymous inner class:
PartitionIterable<Person>> newYorkersAndNonNewYorkers = people.partitionWith(new Predicate2<Person, String>() { public boolean accept(Person person, String state) { return person.getAddress().getState().getName().equals(state); } }, "New York");
partitionWith
in interface RichIterable<T>
<S> SetIterable<S> selectInstancesOf(Class<S> clazz)
RichIterable
clazz
.selectInstancesOf
in interface RichIterable<T>
@Deprecated SetIterable<Pair<T,Integer>> zipWithIndex()
OrderedIterable.zipWithIndex()
instead.RichIterable
RichIterable
with its indices.zipWithIndex
in interface RichIterable<T>
RichIterable
containing pairs consisting of all elements of this RichIterable
paired with their index. Indices start at 0.RichIterable.zip(Iterable)
ParallelSetIterable<T> asParallel(ExecutorService executorService, int batchSize)
boolean equals(Object o)
Set.equals(Object)
.int hashCode()
Set.hashCode()
.ImmutableSetIterable<T> toImmutable()
Copyright © 2004–2016. All rights reserved.