@NotThreadSafe public class UnifiedSetWithHashingStrategy<K> extends Object implements MutableSet<K>, Externalizable, Pool<K>, BatchIterable<K>
| Constructor and Description |
|---|
UnifiedSetWithHashingStrategy()
Deprecated.
No argument default constructor used for serialization. Instantiating an UnifiedSetWithHashingStrategyMultimap with
this constructor will have a null hashingStrategy and throw NullPointerException when used.
|
UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy) |
UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy,
Collection<? extends K> collection) |
UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy,
int initialCapacity) |
UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy,
int initialCapacity,
float loadFactor) |
UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy,
UnifiedSetWithHashingStrategy<K> set) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(K key) |
boolean |
addAll(Collection<? extends K> collection) |
boolean |
addAllIterable(Iterable<? extends K> iterable) |
<K2,V> MutableMap<K2,V> |
aggregateBy(Function<? super K,? extends K2> groupBy,
Function0<? extends V> zeroValueFactory,
Function2<? super V,? super K,? extends V> nonMutatingAggregator)
Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.
|
<K2,V> MutableMap<K2,V> |
aggregateInPlaceBy(Function<? super K,? extends K2> groupBy,
Function0<? extends V> zeroValueFactory,
Procedure2<? super V,? super K> mutatingAggregator)
Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.
|
boolean |
allSatisfy(Predicate<? super K> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.
|
<P> boolean |
allSatisfyWith(Predicate2<? super K,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for every element of the collection, or returns false.
|
boolean |
anySatisfy(Predicate<? super K> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(Predicate2<? super K,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
void |
appendString(Appendable appendable)
Prints a string representation of this collection onto the given
Appendable. |
void |
appendString(Appendable appendable,
String separator)
Prints a string representation of this collection onto the given
Appendable. |
void |
appendString(Appendable appendable,
String start,
String separator,
String end)
Prints a string representation of this collection onto the given
Appendable. |
LazyIterable<K> |
asLazy()
Returns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).
|
MutableSet<K> |
asSynchronized()
Returns a synchronized (thread-safe) collection backed by this collection.
|
MutableSet<K> |
asUnmodifiable()
Returns an unmodifable view of the set.
|
void |
batchForEach(Procedure<? super K> procedure,
int sectionIndex,
int sectionCount) |
<B> LazyIterable<Pair<K,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. |
RichIterable<RichIterable<K>> |
chunk(int size)
Partitions elements in fixed size chunks.
|
void |
clear() |
UnifiedSetWithHashingStrategy<K> |
clone() |
<V> UnifiedSet<V> |
collect(Function<? super K,? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source
collection.
|
<V,R extends Collection<V>> |
collect(Function<? super K,? extends V> function,
R target)
Same as
RichIterable.collect(Function), except that the results are gathered into the specified target
collection. |
MutableBooleanSet |
collectBoolean(BooleanFunction<? super K> booleanFunction)
Returns a new primitive
boolean iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableBooleanCollection> |
collectBoolean(BooleanFunction<? super K> booleanFunction,
R target)
Same as
RichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specified target
collection. |
MutableByteSet |
collectByte(ByteFunction<? super K> byteFunction)
Returns a new primitive
byte iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableByteCollection> |
collectByte(ByteFunction<? super K> byteFunction,
R target)
Same as
RichIterable.collectByte(ByteFunction), except that the results are gathered into the specified target
collection. |
MutableCharSet |
collectChar(CharFunction<? super K> charFunction)
Returns a new primitive
char iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableCharCollection> |
collectChar(CharFunction<? super K> charFunction,
R target)
Same as
RichIterable.collectChar(CharFunction), except that the results are gathered into the specified target
collection. |
MutableDoubleSet |
collectDouble(DoubleFunction<? super K> doubleFunction)
Returns a new primitive
double iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableDoubleCollection> |
collectDouble(DoubleFunction<? super K> doubleFunction,
R target)
Same as
RichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specified target
collection. |
MutableFloatSet |
collectFloat(FloatFunction<? super K> floatFunction)
Returns a new primitive
float iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableFloatCollection> |
collectFloat(FloatFunction<? super K> floatFunction,
R target)
Same as
RichIterable.collectFloat(FloatFunction), except that the results are gathered into the specified target
collection. |
<V> UnifiedSet<V> |
collectIf(Predicate<? super K> predicate,
Function<? super K,? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source
collection, but only for those elements which return true upon evaluation of the predicate.
|
<V,R extends Collection<V>> |
collectIf(Predicate<? super K> predicate,
Function<? super K,? extends V> function,
R target)
Same as the collectIf method with two parameters but uses the specified target collection for the results.
|
MutableIntSet |
collectInt(IntFunction<? super K> intFunction)
Returns a new primitive
int iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableIntCollection> |
collectInt(IntFunction<? super K> intFunction,
R target)
Same as
RichIterable.collectInt(IntFunction), except that the results are gathered into the specified target
collection. |
MutableLongSet |
collectLong(LongFunction<? super K> longFunction)
Returns a new primitive
long iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableLongCollection> |
collectLong(LongFunction<? super K> longFunction,
R target)
Same as
RichIterable.collectLong(LongFunction), except that the results are gathered into the specified target
collection. |
MutableShortSet |
collectShort(ShortFunction<? super K> shortFunction)
Returns a new primitive
short iterable with the results of applying the specified function on each element
of the source collection. |
<R extends MutableShortCollection> |
collectShort(ShortFunction<? super K> shortFunction,
R target)
Same as
RichIterable.collectShort(ShortFunction), except that the results are gathered into the specified target
collection. |
<P,A> UnifiedSet<A> |
collectWith(Function2<? super K,? super P,? extends A> function,
P parameter)
Same as collect with a
Function2 and specified parameter which is passed to the block
|
<P,A,R extends Collection<A>> |
collectWith(Function2<? super K,? super P,? extends A> function,
P parameter,
R targetCollection)
Same as collectWith but with a targetCollection parameter to gather the results.
|
boolean |
contains(Object key)
Returns true if the iterable has an element which responds true to element.equals(object).
|
boolean |
containsAll(Collection<?> collection)
Returns true if all elements in source are contained in this collection.
|
boolean |
containsAllArguments(Object... elements)
Returns true if all elements in the specified var arg array are contained in this collection.
|
boolean |
containsAllIterable(Iterable<?> source)
Returns true if all elements in source are contained in this collection.
|
int |
count(Predicate<? super K> predicate)
Return the total number of elements that answer true to the specified predicate.
|
<P> int |
countWith(Predicate2<? super K,? super P> predicate,
P parameter)
Returns the total number of elements that evaluate to true for the specified predicate.
|
K |
detect(Predicate<? super K> predicate)
Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no
element returns true.
|
K |
detectIfNone(Predicate<? super K> predicate,
Function0<? extends K> function)
Returns the first element of the iterable for which the predicate evaluates to true.
|
<P> K |
detectWith(Predicate2<? super K,? super P> predicate,
P parameter)
Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none
evaluate to true.
|
<P> K |
detectWithIfNone(Predicate2<? super K,? super P> predicate,
P parameter,
Function0<? extends K> function)
Returns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or
returns the value of evaluating the specified function.
|
MutableSet<K> |
difference(SetIterable<? extends K> subtrahendSet)
Returns the set of all members of
this that are not members of subtrahendSet. |
<R extends Set<K>> |
differenceInto(SetIterable<? extends K> subtrahendSet,
R targetSet)
Same as
SetIterable.difference(SetIterable) but adds all the objects to targetSet and returns it. |
boolean |
equals(Object object)
Follows the same general contract as
Set.equals(Object). |
<V> UnifiedSet<V> |
flatCollect(Function<? super K,? extends Iterable<V>> function)
flatCollect is a special case of RichIterable.collect(Function). |
<V,R extends Collection<V>> |
flatCollect(Function<? super K,? extends Iterable<V>> function,
R target)
Same as flatCollect, only the results are collected into the target collection.
|
void |
forEach(Procedure<? super K> procedure)
The procedure is executed for each element in the iterable.
|
<P> void |
forEachWith(Procedure2<? super K,? super P> procedure,
P parameter)
The procedure2 is evaluated for each element in the iterable with the specified parameter provided
as the second argument.
|
void |
forEachWithIndex(ObjectIntProcedure<? super K> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure
|
K |
get(K key)
Locates an object in the pool which is equal to
key. |
int |
getBatchCount(int batchSize) |
K |
getFirst()
Returns the first element of an iterable.
|
K |
getLast()
Returns the last element of an iterable.
|
<V> UnifiedSetWithHashingStrategyMultimap<V,K> |
groupBy(Function<? super K,? extends V> function)
For each element of the iterable, the function is evaluated and the results of these evaluations are collected
into a new multimap, where the transformed value is the key and the original values are added to the same (or similar)
species of collection as the source iterable.
|
<V,R extends MutableMultimap<V,K>> |
groupBy(Function<? super K,? extends V> function,
R target)
Same as
RichIterable.groupBy(Function), except that the results are gathered into the specified target
multimap. |
<V> UnifiedSetMultimap<V,K> |
groupByEach(Function<? super K,? extends Iterable<V>> function)
Similar to
RichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
for each value. |
<V,R extends MutableMultimap<V,K>> |
groupByEach(Function<? super K,? extends Iterable<V>> function,
R target)
Same as
RichIterable.groupByEach(Function), except that the results are gathered into the specified target
multimap. |
<V> MutableMap<V,K> |
groupByUniqueKey(Function<? super K,? extends V> function)
For each element of the iterable, the function is evaluated and he results of these evaluations are collected
into a new map, where the transformed value is the key.
|
int |
hashCode()
Follows the same general contract as
Set.hashCode(). |
HashingStrategy<? super K> |
hashingStrategy() |
double |
injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super K> function)
Returns the final double result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
float |
injectInto(float injectedValue,
FloatObjectToFloatFunction<? super K> function)
Returns the final float result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
int |
injectInto(int injectedValue,
IntObjectToIntFunction<? super K> function)
Returns the final int result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
<IV> IV |
injectInto(IV injectedValue,
Function2<? super IV,? super K,? extends IV> function)
Returns the final result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
long |
injectInto(long injectedValue,
LongObjectToLongFunction<? super K> function)
Returns the final long result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
<IV,P> IV |
injectIntoWith(IV injectValue,
Function3<? super IV,? super K,? super P,? extends IV> function,
P parameter) |
MutableSet<K> |
intersect(SetIterable<? extends K> set)
Returns the set of all objects that are members of both
this and set. |
<R extends Set<K>> |
intersectInto(SetIterable<? extends K> set,
R targetSet)
Same as
SetIterable.intersect(SetIterable) but adds all the objects to targetSet and returns it. |
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
boolean |
isProperSubsetOf(SetIterable<? extends K> 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 K> candidateSuperset)
Returns true if all the members of
this are also members of candidateSuperset. |
Iterator<K> |
iterator() |
<V> LazyIterable<V> |
lazyCollect(Function<? super K,? extends V> function)
Deprecated.
since 3.0. Use
asLazy().collect(Function) instead. |
LazyIterable<K> |
lazyReject(Predicate<? super K> predicate)
Deprecated.
since 3.0. Use
asLazy().reject(Predicate) instead. |
LazyIterable<K> |
lazySelect(Predicate<? super K> predicate)
Deprecated.
since 3.0. Use
asLazy().select(Predicate) instead. |
String |
makeString()
Returns a string representation of this collection by delegating to
RichIterable.makeString(String) and defaulting
the separator parameter to the characters ", " (comma and space). |
String |
makeString(String separator)
Returns a string representation of this collection by delegating to
RichIterable.makeString(String, String, String)
and defaulting the start and end parameters to "" (the empty String). |
String |
makeString(String start,
String separator,
String end)
Returns a string representation of this collection.
|
K |
max()
Returns the maximum element out of this container based on the natural order.
|
K |
max(Comparator<? super K> comparator)
Returns the maximum element out of this container based on the comparator.
|
<V extends Comparable<? super V>> |
maxBy(Function<? super K,? extends V> function)
Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.
|
K |
min()
Returns the minimum element out of this container based on the natural order.
|
K |
min(Comparator<? super K> comparator)
Returns the minimum element out of this container based on the comparator.
|
<V extends Comparable<? super V>> |
minBy(Function<? super K,? extends V> function)
Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.
|
UnifiedSetWithHashingStrategy<K> |
newEmpty()
Creates a new empty mutable version of the same collection type.
|
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(HashingStrategy<? super K> hashingStrategy) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(HashingStrategy<? super K> hashingStrategy,
int size) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(HashingStrategy<? super K> hashingStrategy,
int size,
float loadFactor) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(HashingStrategy<? super K> hashingStrategy,
Iterable<? extends K> source) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(UnifiedSetWithHashingStrategy<K> set) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSetWith(HashingStrategy<? super K> hashingStrategy,
K... elements) |
boolean |
noneSatisfy(Predicate<? super K> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.
|
<P> boolean |
noneSatisfyWith(Predicate2<? super K,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
boolean |
notEmpty()
The English equivalent of !this.isEmpty()
|
PartitionMutableSet<K> |
partition(Predicate<? super K> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
<P> PartitionMutableSet<K> |
partitionWith(Predicate2<? super K,? super P> predicate,
P parameter)
Filters a collection into a PartitionIterable based on the evaluation of the predicate.
|
MutableSet<UnsortedSetIterable<K>> |
powerSet()
Returns the set whose members are all possible subsets of
this. |
K |
put(K key)
Puts
key into the pool. |
void |
readExternal(ObjectInput in) |
UnifiedSetWithHashingStrategy<K> |
reject(Predicate<? super K> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.
|
<R extends Collection<K>> |
reject(Predicate<? super K> predicate,
R target)
Same as the reject method with one parameter but uses the specified target collection for the results.
|
<P> UnifiedSetWithHashingStrategy<K> |
rejectWith(Predicate2<? super K,? super P> predicate,
P parameter)
Similar to
RichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2. |
<P,R extends Collection<K>> |
rejectWith(Predicate2<? super K,? super P> predicate,
P parameter,
R targetCollection)
Similar to
RichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2. |
boolean |
remove(Object key) |
boolean |
removeAll(Collection<?> collection) |
boolean |
removeAllIterable(Iterable<?> iterable) |
K |
removeFromPool(K key)
Locates an object in the pool which is equal to
key and removes it. |
void |
removeIf(Predicate<? super K> predicate)
Removes all elements in the collection that evaluate to true for the specified predicate.
|
<P> void |
removeIfWith(Predicate2<? super K,? super P> predicate,
P parameter)
Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.
|
boolean |
retainAll(Collection<?> collection) |
boolean |
retainAllIterable(Iterable<?> iterable) |
UnifiedSetWithHashingStrategy<K> |
select(Predicate<? super K> predicate)
Returns all elements of the source collection that return true when evaluating the predicate.
|
<R extends Collection<K>> |
select(Predicate<? super K> predicate,
R target)
Same as the select method with one parameter but uses the specified target collection for the results.
|
<P> Twin<MutableList<K>> |
selectAndRejectWith(Predicate2<? super K,? super P> predicate,
P parameter)
Filters a collection into two separate collections based on a predicate returned via a Pair.
|
<S> UnifiedSetWithHashingStrategy<S> |
selectInstancesOf(Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz. |
<P> UnifiedSetWithHashingStrategy<K> |
selectWith(Predicate2<? super K,? super P> predicate,
P parameter)
Similar to
RichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2. |
<P,R extends Collection<K>> |
selectWith(Predicate2<? super K,? super P> predicate,
P parameter,
R targetCollection)
Similar to
RichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2. |
int |
size()
Returns the number of items in this iterable.
|
double |
sumOfDouble(DoubleFunction<? super K> function)
Returns the final double result of evaluating function for each element of the iterable and adding the results
together.
|
double |
sumOfFloat(FloatFunction<? super K> function)
Returns the final double result of evaluating function for each element of the iterable and adding the results
together.
|
long |
sumOfInt(IntFunction<? super K> function)
Returns the final long result of evaluating function for each element of the iterable and adding the results
together.
|
long |
sumOfLong(LongFunction<? super K> function)
Returns the final long result of evaluating function for each element of the iterable and adding the results
together.
|
MutableSet<K> |
symmetricDifference(SetIterable<? extends K> 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<K>> |
symmetricDifferenceInto(SetIterable<? extends K> set,
R targetSet)
Same as
SetIterable.symmetricDifference(SetIterable) but adds all the objects to targetSet and returns it. |
Object[] |
toArray()
Converts this iterable to an array.
|
<T> T[] |
toArray(T[] array)
Converts this iterable to an array using the specified target array, assuming the target array is as long
or longer than the iterable.
|
MutableBag<K> |
toBag()
Converts the collection to the default MutableBag implementation.
|
ImmutableSet<K> |
toImmutable()
Returns an immutable copy of this set.
|
MutableList<K> |
toList()
Converts the collection to a MutableList implementation.
|
<NK,NV> MutableMap<NK,NV> |
toMap(Function<? super K,? extends NK> keyFunction,
Function<? super K,? extends NV> valueFunction)
Converts the collection to a MutableMap implementation using the specified key and value functions.
|
UnifiedSet<K> |
toSet()
Converts the collection to a MutableSet implementation.
|
MutableList<K> |
toSortedList()
Converts the collection to a MutableList implementation and sorts it using the natural order of the elements.
|
MutableList<K> |
toSortedList(Comparator<? super K> comparator)
Converts the collection to a MutableList implementation and sorts it using the specified comparator.
|
<V extends Comparable<? super V>> |
toSortedListBy(Function<? super K,? extends V> function)
Converts the collection to a MutableList implementation and sorts it based on the natural order of the
attribute returned by
function. |
<NK,NV> MutableSortedMap<NK,NV> |
toSortedMap(Comparator<? super NK> comparator,
Function<? super K,? extends NK> keyFunction,
Function<? super K,? extends NV> valueFunction)
Converts the collection to a MutableSortedMap implementation using the specified key and value functions
sorted by the given comparator.
|
<NK,NV> MutableSortedMap<NK,NV> |
toSortedMap(Function<? super K,? extends NK> keyFunction,
Function<? super K,? extends NV> valueFunction)
Converts the collection to a MutableSortedMap implementation using the specified key and value functions
sorted by the key elements' natural ordering.
|
MutableSortedSet<K> |
toSortedSet()
Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the
elements.
|
MutableSortedSet<K> |
toSortedSet(Comparator<? super K> comparator)
Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.
|
<V extends Comparable<? super V>> |
toSortedSetBy(Function<? super K,? extends V> function)
Converts the collection to a MutableSortedSet implementation and sorts it based on the natural order of the
attribute returned by
function. |
String |
toString()
Returns a string representation of this RichIterable.
|
MutableSet<K> |
union(SetIterable<? extends K> set)
Returns the set of all objects that are a member of
this or set or both. |
<R extends Set<K>> |
unionInto(SetIterable<? extends K> set,
R targetSet)
Same as
SetIterable.union(SetIterable) but adds all the objects to targetSet and returns it. |
UnifiedSetWithHashingStrategy<K> |
with(K... elements) |
UnifiedSetWithHashingStrategy<K> |
with(K element)
This method allows mutable and fixed size collections the ability to add elements to their existing elements.
|
UnifiedSetWithHashingStrategy<K> |
with(K element1,
K element2) |
UnifiedSetWithHashingStrategy<K> |
with(K element1,
K element2,
K element3) |
UnifiedSetWithHashingStrategy<K> |
withAll(Iterable<? extends K> iterable)
This method allows mutable and fixed size collections the ability to add multiple elements to their existing
elements.
|
UnifiedSetWithHashingStrategy<K> |
without(K element)
This method allows mutable and fixed size collections the ability to remove elements from their existing elements.
|
UnifiedSetWithHashingStrategy<K> |
withoutAll(Iterable<? extends K> elements)
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing
elements.
|
void |
writeExternal(ObjectOutput out) |
<S> MutableSet<Pair<K,S>> |
zip(Iterable<S> that)
Returns a
RichIterable formed from this RichIterable and another RichIterable by
combining corresponding elements in pairs. |
<S,R extends Collection<Pair<K,S>>> |
zip(Iterable<S> that,
R target)
Same as
RichIterable.zip(Iterable) but uses target for output. |
MutableSet<Pair<K,Integer>> |
zipWithIndex()
Zips this
RichIterable with its indices. |
<R extends Collection<Pair<K,Integer>>> |
zipWithIndex(R target)
Same as
RichIterable.zipWithIndex() but uses target for output. |
forEach, spliteratorspliteratorparallelStream, removeIf, stream@Deprecated public UnifiedSetWithHashingStrategy()
public UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy)
public UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, int initialCapacity)
public UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, int initialCapacity, float loadFactor)
public UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Collection<? extends K> collection)
public UnifiedSetWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, UnifiedSetWithHashingStrategy<K> set)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(UnifiedSetWithHashingStrategy<K> set)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy, int size)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy, Iterable<? extends K> source)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy, int size, float loadFactor)
public static <K> UnifiedSetWithHashingStrategy<K> newSetWith(HashingStrategy<? super K> hashingStrategy, K... elements)
public HashingStrategy<? super K> hashingStrategy()
public void clear()
public boolean add(K key)
public boolean contains(Object key)
RichIterablecontains in interface RichIterable<K>contains in interface Collection<K>contains in interface Set<K>public int getBatchCount(int batchSize)
getBatchCount in interface BatchIterable<K>public void batchForEach(Procedure<? super K> procedure, int sectionIndex, int sectionCount)
batchForEach in interface BatchIterable<K>public void forEach(Procedure<? super K> procedure)
InternalIterablee.g. people.forEach(new Procedure() { public void value(Person person) { LOGGER.info(person.getName()); } });
forEach in interface InternalIterable<K>forEach in interface BatchIterable<K>public <P> void forEachWith(Procedure2<? super K,? super P> procedure, P parameter)
InternalIterablee.g. people.forEachWith(new Procedure2() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
forEachWith in interface InternalIterable<K>public void forEachWithIndex(ObjectIntProcedure<? super K> objectIntProcedure)
InternalIterablee.g. people.forEachWithIndex(new ObjectIntProcedure() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex in interface InternalIterable<K>public UnifiedSetWithHashingStrategy<K> newEmpty()
MutableCollectionnewEmpty in interface MutableCollection<K>newEmpty in interface MutableSet<K>public K getFirst()
RichIterablegetFirst in interface RichIterable<K>public K getLast()
RichIterablegetLast in interface RichIterable<K>public UnifiedSetWithHashingStrategy<K> select(Predicate<? super K> predicate)
RichIterablee.g.
return people.select(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.getAddress().getCity().equals("Metuchen");
}
});
select in interface MutableCollection<K>select in interface RichIterable<K>select in interface MutableSet<K>select in interface SetIterable<K>select in interface UnsortedSetIterable<K>public <R extends Collection<K>> R select(Predicate<? super K> predicate, R target)
RichIterablee.g.
return people.select(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.person.getLastName().equals("Smith");
}
}, Lists.mutable.of());
e.g.
return collection.select(Predicates.attributeEqual("lastName", "Smith"), new ArrayList());
select in interface RichIterable<K>predicate - a Predicate to use as the select criteriatarget - the Collection to append to for all elements in this RichIterable that meet select criteria predicatetarget, which contains appended elements as a result of the select criteriaRichIterable.select(Predicate)public <P> UnifiedSetWithHashingStrategy<K> selectWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterableRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.selectWith in interface MutableCollection<K>selectWith in interface RichIterable<K>selectWith in interface MutableSet<K>selectWith in interface SetIterable<K>selectWith in interface UnsortedSetIterable<K>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicateRichIterable.select(Predicate)public <P,R extends Collection<K>> R selectWith(Predicate2<? super K,? super P> predicate, P parameter, R targetCollection)
RichIterableRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.selectWith in interface RichIterable<K>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicatetargetCollection - the Collection to append to for all elements in this RichIterable that meet select criteria predicatetargetCollection, which contains appended elements as a result of the select criteriaRichIterable.select(Predicate),
RichIterable.select(Predicate, Collection)public UnifiedSetWithHashingStrategy<K> reject(Predicate<? super K> predicate)
RichIterablee.g.
return people.reject(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.person.getLastName().equals("Smith");
}
});
e.g.
return people.reject(Predicates.attributeEqual("lastName", "Smith"));
reject in interface MutableCollection<K>reject in interface RichIterable<K>reject in interface MutableSet<K>reject in interface SetIterable<K>reject in interface UnsortedSetIterable<K>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic <R extends Collection<K>> R reject(Predicate<? super K> predicate, R target)
RichIterablee.g.
return people.reject(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.person.getLastName().equals("Smith");
}
}, Lists.mutable.of());
reject in interface RichIterable<K>predicate - a Predicate to use as the reject criteriatarget - the Collection to append to for all elements in this RichIterable that cause Predicate#accept(Object) method to evaluate to falsetarget, which contains appended elements as a result of the reject criteriapublic <P> UnifiedSetWithHashingStrategy<K> rejectWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterableRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.rejectWith in interface MutableCollection<K>rejectWith in interface RichIterable<K>rejectWith in interface MutableSet<K>rejectWith in interface SetIterable<K>rejectWith in interface UnsortedSetIterable<K>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicateRichIterable.select(Predicate)public <P,R extends Collection<K>> R rejectWith(Predicate2<? super K,? super P> predicate, P parameter, R targetCollection)
RichIterableRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.
E.g. return a Collection of Person elements where the person has a height greater than 100cm
return people.reject(new Predicate2<Person, Integer>()
{
public boolean accept(Person p, Integer i)
{
return p.getHeightInCm() < i.intValue();
}
}, Integer.valueOf(100), FastList.newList());
rejectWith in interface RichIterable<K>predicate - a Predicate2 to use as the reject criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicatetargetCollection - the Collection to append to for all elements in this RichIterable that cause Predicate#accept(Object) method to evaluate to falsetargetCollection, which contains appended elements as a result of the reject criteriaRichIterable.reject(Predicate),
RichIterable.reject(Predicate, Collection)public <P> Twin<MutableList<K>> selectAndRejectWith(Predicate2<? super K,? super P> predicate, P parameter)
MutableCollectione.g. return lastNames.selectAndRejectWith(PredicatesLite.lessThan(), "Mason");
selectAndRejectWith in interface MutableCollection<K>public PartitionMutableSet<K> partition(Predicate<? super K> predicate)
RichIterablee.g.
return people.partition(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.getAddress().getState().getName().equals("New York");
}
});
partition in interface MutableCollection<K>partition in interface RichIterable<K>partition in interface MutableSet<K>partition in interface SetIterable<K>public <P> PartitionMutableSet<K> partitionWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterablee.g.
return 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 MutableCollection<K>partitionWith in interface RichIterable<K>partitionWith in interface MutableSet<K>partitionWith in interface SetIterable<K>public <S> UnifiedSetWithHashingStrategy<S> selectInstancesOf(Class<S> clazz)
RichIterableclazz.selectInstancesOf in interface MutableCollection<K>selectInstancesOf in interface RichIterable<K>selectInstancesOf in interface MutableSet<K>selectInstancesOf in interface SetIterable<K>selectInstancesOf in interface UnsortedSetIterable<K>public void removeIf(Predicate<? super K> predicate)
MutableCollectione.g. return lastNames.removeIf(Predicates.isNull());
removeIf in interface MutableCollection<K>public <P> void removeIfWith(Predicate2<? super K,? super P> predicate, P parameter)
MutableCollectione.g. return lastNames.removeIfWith(PredicatesLite.isNull(), null);
removeIfWith in interface MutableCollection<K>public <V> UnifiedSet<V> collect(Function<? super K,? extends V> function)
RichIterablee.g.
return people.collect(new Function<Person, String>()
{
public String valueOf(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
});
collect in interface MutableCollection<K>collect in interface RichIterable<K>collect in interface MutableSet<K>collect in interface UnsortedSetIterable<K>public MutableBooleanSet collectBoolean(BooleanFunction<? super K> booleanFunction)
RichIterableboolean iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectBoolean(new BooleanFunction<Person>()
{
public boolean booleanValueOf(Person person)
{
return person.hasDrivingLicense();
}
});
collectBoolean in interface MutableCollection<K>collectBoolean in interface RichIterable<K>collectBoolean in interface MutableSet<K>collectBoolean in interface UnsortedSetIterable<K>public <R extends MutableBooleanCollection> R collectBoolean(BooleanFunction<? super K> booleanFunction, R target)
RichIterableRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectBoolean(new BooleanFunction<Person>()
{
public boolean booleanValueOf(Person person)
{
return person.hasDrivingLicense();
}
}, new BooleanArrayList());
collectBoolean in interface RichIterable<K>booleanFunction - a BooleanFunction to use as the collect transformation functiontarget - the MutableBooleanCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableByteSet collectByte(ByteFunction<? super K> byteFunction)
RichIterablebyte iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectByte(new ByteFunction<Person>()
{
public byte byteValueOf(Person person)
{
return person.getCode();
}
});
collectByte in interface MutableCollection<K>collectByte in interface RichIterable<K>collectByte in interface MutableSet<K>collectByte in interface UnsortedSetIterable<K>public <R extends MutableByteCollection> R collectByte(ByteFunction<? super K> byteFunction, R target)
RichIterableRichIterable.collectByte(ByteFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectByte(new ByteFunction<Person>()
{
public byte byteValueOf(Person person)
{
return person.getCode();
}
}, new ByteArrayList());
collectByte in interface RichIterable<K>byteFunction - a ByteFunction to use as the collect transformation functiontarget - the MutableByteCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableCharSet collectChar(CharFunction<? super K> charFunction)
RichIterablechar iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectChar(new CharFunction<Person>()
{
public char charValueOf(Person person)
{
return person.getMiddleInitial();
}
});
collectChar in interface MutableCollection<K>collectChar in interface RichIterable<K>collectChar in interface MutableSet<K>collectChar in interface UnsortedSetIterable<K>public <R extends MutableCharCollection> R collectChar(CharFunction<? super K> charFunction, R target)
RichIterableRichIterable.collectChar(CharFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectChar(new CharFunction<Person>()
{
public char charValueOf(Person person)
{
return person.getMiddleInitial();
}
}, new CharArrayList());
collectChar in interface RichIterable<K>charFunction - a CharFunction to use as the collect transformation functiontarget - the MutableCharCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableDoubleSet collectDouble(DoubleFunction<? super K> doubleFunction)
RichIterabledouble iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectDouble(new DoubleFunction<Person>()
{
public double doubleValueOf(Person person)
{
return person.getMilesFromNorthPole();
}
});
collectDouble in interface MutableCollection<K>collectDouble in interface RichIterable<K>collectDouble in interface MutableSet<K>collectDouble in interface UnsortedSetIterable<K>public <R extends MutableDoubleCollection> R collectDouble(DoubleFunction<? super K> doubleFunction, R target)
RichIterableRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectDouble(new DoubleFunction<Person>()
{
public double doubleValueOf(Person person)
{
return person.getMilesFromNorthPole();
}
}, new DoubleArrayList());
collectDouble in interface RichIterable<K>doubleFunction - a DoubleFunction to use as the collect transformation functiontarget - the MutableDoubleCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableFloatSet collectFloat(FloatFunction<? super K> floatFunction)
RichIterablefloat iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectFloat(new FloatFunction<Person>()
{
public float floatValueOf(Person person)
{
return person.getHeightInInches();
}
});
collectFloat in interface MutableCollection<K>collectFloat in interface RichIterable<K>collectFloat in interface MutableSet<K>collectFloat in interface UnsortedSetIterable<K>public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super K> floatFunction, R target)
RichIterableRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectFloat(new FloatFunction<Person>()
{
public float floatValueOf(Person person)
{
return person.getHeightInInches();
}
}, new FloatArrayList());
collectFloat in interface RichIterable<K>floatFunction - a FloatFunction to use as the collect transformation functiontarget - the MutableFloatCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableIntSet collectInt(IntFunction<? super K> intFunction)
RichIterableint iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectInt(new IntFunction<Person>()
{
public int intValueOf(Person person)
{
return person.getAge();
}
});
collectInt in interface MutableCollection<K>collectInt in interface RichIterable<K>collectInt in interface MutableSet<K>collectInt in interface UnsortedSetIterable<K>public <R extends MutableIntCollection> R collectInt(IntFunction<? super K> intFunction, R target)
RichIterableRichIterable.collectInt(IntFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectInt(new IntFunction<Person>()
{
public int intValueOf(Person person)
{
return person.getAge();
}
}, new IntArrayList());
collectInt in interface RichIterable<K>intFunction - a IntFunction to use as the collect transformation functiontarget - the MutableIntCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableLongSet collectLong(LongFunction<? super K> longFunction)
RichIterablelong iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectLong(new LongFunction<Person>()
{
public long longValueOf(Person person)
{
return person.getGuid();
}
});
collectLong in interface MutableCollection<K>collectLong in interface RichIterable<K>collectLong in interface MutableSet<K>collectLong in interface UnsortedSetIterable<K>public <R extends MutableLongCollection> R collectLong(LongFunction<? super K> longFunction, R target)
RichIterableRichIterable.collectLong(LongFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectLong(new LongFunction<Person>()
{
public long longValueOf(Person person)
{
return person.getGuid();
}
}, new LongArrayList());
collectLong in interface RichIterable<K>longFunction - a LongFunction to use as the collect transformation functiontarget - the MutableLongCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic MutableShortSet collectShort(ShortFunction<? super K> shortFunction)
RichIterableshort iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g.
return people.collectShort(new ShortFunction<Person>()
{
public short shortValueOf(Person person)
{
return person.getNumberOfJunkMailItemsReceivedPerMonth();
}
});
collectShort in interface MutableCollection<K>collectShort in interface RichIterable<K>collectShort in interface MutableSet<K>collectShort in interface UnsortedSetIterable<K>public <R extends MutableShortCollection> R collectShort(ShortFunction<? super K> shortFunction, R target)
RichIterableRichIterable.collectShort(ShortFunction), except that the results are gathered into the specified target
collection.
e.g.
return people.collectShort(new ShortFunction<Person>()
{
public short shortValueOf(Person person)
{
return person.getNumberOfJunkMailItemsReceivedPerMonth;
}
}, new ShortArrayList());
collectShort in interface RichIterable<K>shortFunction - a ShortFunction to use as the collect transformation functiontarget - the MutableShortCollection to append to for all elements in this RichIterabletarget, which contains appended elements as a result of the collect transformationpublic <V,R extends Collection<V>> R collect(Function<? super K,? extends V> function, R target)
RichIterableRichIterable.collect(Function), except that the results are gathered into the specified target
collection.
e.g.
return people.collect(new Function<Person, String>()
{
public String valueOf(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
}, Lists.mutable.of());
collect in interface RichIterable<K>function - a Function to use as the collect transformation functiontarget - the Collection to append to for all elements in this RichIterable that meet select criteria functiontarget, which contains appended elements as a result of the collect transformationRichIterable.collect(Function)public <V> UnifiedSet<V> flatCollect(Function<? super K,? extends Iterable<V>> function)
RichIterableflatCollect is a special case of RichIterable.collect(Function). With collect, when the Function returns
a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection
instead. This method is commonly called flatMap.
Consider the following example where we have a Person class, and each Person has a list of Address objects. Take the following Function:
Function<Person, List<Address>> addressFunction = new Function<Person, List<Address>>()
{
public List<Address> valueOf(Person person)
{
return person.getAddresses();
}
};
MutableList<Person> people = ...;
Using collect returns a collection of collections of addresses.
MutableList<List<Address>> addresses = people.collect(addressFunction);Using
flatCollect returns a single flattened list of addresses.
MutableList<Address> addresses = people.flatCollect(addressFunction);
flatCollect in interface MutableCollection<K>flatCollect in interface RichIterable<K>flatCollect in interface MutableSet<K>flatCollect in interface UnsortedSetIterable<K>function - The Function to applyfunctionpublic <V,R extends Collection<V>> R flatCollect(Function<? super K,? extends Iterable<V>> function, R target)
RichIterableflatCollect in interface RichIterable<K>function - The Function to applytarget - The collection into which results should be added.target, which will contain a flattened collection of results produced by applying the given functionRichIterable.flatCollect(Function)public <P,A> UnifiedSet<A> collectWith(Function2<? super K,? super P,? extends A> function, P parameter)
RichIterableFunction2 and specified parameter which is passed to the block
e.g. Function2addParameterFunction = new Function2 () { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; FastList.newListWith(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1));
collectWith in interface MutableCollection<K>collectWith in interface RichIterable<K>collectWith in interface MutableSet<K>collectWith in interface UnsortedSetIterable<K>function - A Function2 to use as the collect transformation functionparameter - A parameter to pass in for evaluation of the second argument P in functionRichIterable that contains the transformed elements returned by Function2.value(Object, Object)RichIterable.collect(Function)public <P,A,R extends Collection<A>> R collectWith(Function2<? super K,? super P,? extends A> function, P parameter, R targetCollection)
RichIterablee.g. Function2addParameterFunction = new Function2 () { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; FastList.newListWith(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), UnifiedSet.newSet());
collectWith in interface RichIterable<K>function - a Function2 to use as the collect transformation functionparameter - a parameter to pass in for evaluation of the second argument P in functiontargetCollection - the Collection to append to for all elements in this RichIterable that meet select criteria functiontargetCollection, which contains appended elements as a result of the collect transformationpublic <V> UnifiedSet<V> collectIf(Predicate<? super K> predicate, Function<? super K,? extends V> function)
RichIterablee.g. Lists.mutable.of().with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString())
collectIf in interface MutableCollection<K>collectIf in interface RichIterable<K>collectIf in interface MutableSet<K>collectIf in interface UnsortedSetIterable<K>public <V,R extends Collection<V>> R collectIf(Predicate<? super K> predicate, Function<? super K,? extends V> function, R target)
RichIterablecollectIf in interface RichIterable<K>predicate - a Predicate to use as the select criteriafunction - a Function to use as the collect transformation functiontarget - the Collection to append to for all elements in this RichIterable that meet the collect criteria predicatetargetCollection, which contains appended elements as a result of the collect criteria and transformationRichIterable.collectIf(Predicate, Function)public K detect(Predicate<? super K> predicate)
RichIterablee.g.
return people.detect(new Predicate<Person>()
{
public boolean value(Person person)
{
return person.getFirstName().equals("John") && person.getLastName().equals("Smith");
}
});
detect in interface RichIterable<K>public K min(Comparator<? super K> comparator)
RichIterablemin in interface RichIterable<K>public K max(Comparator<? super K> comparator)
RichIterablemax in interface RichIterable<K>public K min()
RichIterablemin in interface RichIterable<K>public K max()
RichIterablemax in interface RichIterable<K>public <V extends Comparable<? super V>> K minBy(Function<? super K,? extends V> function)
RichIterableminBy in interface RichIterable<K>public <V extends Comparable<? super V>> K maxBy(Function<? super K,? extends V> function)
RichIterablemaxBy in interface RichIterable<K>public K detectIfNone(Predicate<? super K> predicate, Function0<? extends K> function)
RichIterabledetectIfNone in interface RichIterable<K>public <P> K detectWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterablee.g.
people.detectWith(new Predicate2<Person, String>()
{
public boolean value(Person person, String fullName)
{
return person.getFullName().equals(fullName);
}
}, "John Smith");
detectWith in interface RichIterable<K>public <P> K detectWithIfNone(Predicate2<? super K,? super P> predicate, P parameter, Function0<? extends K> function)
RichIterabledetectWithIfNone in interface RichIterable<K>public int count(Predicate<? super K> predicate)
RichIterablee.g.
return people.count(new Predicate<Person>()
{
public boolean value(Person person)
{
return person.getAddress().getState().getName().equals("New York");
}
});
count in interface RichIterable<K>public <P> int countWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterablee.g. return lastNames.countWith(PredicatesLite.equal(), "Smith");
countWith in interface RichIterable<K>public boolean anySatisfy(Predicate<? super K> predicate)
RichIterableanySatisfy in interface RichIterable<K>public <P> boolean anySatisfyWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterableanySatisfyWith in interface RichIterable<K>public boolean allSatisfy(Predicate<? super K> predicate)
RichIterableallSatisfy in interface RichIterable<K>public <P> boolean allSatisfyWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterableallSatisfyWith in interface RichIterable<K>public boolean noneSatisfy(Predicate<? super K> predicate)
RichIterablenoneSatisfy in interface RichIterable<K>public <P> boolean noneSatisfyWith(Predicate2<? super K,? super P> predicate, P parameter)
RichIterablenoneSatisfyWith in interface RichIterable<K>public <IV> IV injectInto(IV injectedValue,
Function2<? super IV,? super K,? extends IV> function)
RichIterableinjectInto in interface RichIterable<K>public int injectInto(int injectedValue,
IntObjectToIntFunction<? super K> function)
RichIterableinjectInto in interface RichIterable<K>public long injectInto(long injectedValue,
LongObjectToLongFunction<? super K> function)
RichIterableinjectInto in interface RichIterable<K>public double injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super K> function)
RichIterableinjectInto in interface RichIterable<K>public float injectInto(float injectedValue,
FloatObjectToFloatFunction<? super K> function)
RichIterableinjectInto in interface RichIterable<K>public long sumOfInt(IntFunction<? super K> function)
RichIterablesumOfInt in interface RichIterable<K>public double sumOfFloat(FloatFunction<? super K> function)
RichIterablesumOfFloat in interface RichIterable<K>public long sumOfLong(LongFunction<? super K> function)
RichIterablesumOfLong in interface RichIterable<K>public double sumOfDouble(DoubleFunction<? super K> function)
RichIterablesumOfDouble in interface RichIterable<K>public <IV,P> IV injectIntoWith(IV injectValue,
Function3<? super IV,? super K,? super P,? extends IV> function,
P parameter)
injectIntoWith in interface MutableCollection<K>@Deprecated public LazyIterable<K> lazySelect(Predicate<? super K> predicate)
asLazy().select(Predicate) instead.@Deprecated public LazyIterable<K> lazyReject(Predicate<? super K> predicate)
asLazy().reject(Predicate) instead.@Deprecated public <V> LazyIterable<V> lazyCollect(Function<? super K,? extends V> function)
asLazy().collect(Function) instead.public MutableList<K> toList()
RichIterabletoList in interface RichIterable<K>public MutableList<K> toSortedList()
RichIterabletoSortedList in interface RichIterable<K>public MutableList<K> toSortedList(Comparator<? super K> comparator)
RichIterabletoSortedList in interface RichIterable<K>public <V extends Comparable<? super V>> MutableList<K> toSortedListBy(Function<? super K,? extends V> function)
RichIterablefunction.toSortedListBy in interface RichIterable<K>public MutableSortedSet<K> toSortedSet()
RichIterabletoSortedSet in interface RichIterable<K>public MutableSortedSet<K> toSortedSet(Comparator<? super K> comparator)
RichIterabletoSortedSet in interface RichIterable<K>public <V extends Comparable<? super V>> MutableSortedSet<K> toSortedSetBy(Function<? super K,? extends V> function)
RichIterablefunction.toSortedSetBy in interface RichIterable<K>public UnifiedSet<K> toSet()
RichIterabletoSet in interface RichIterable<K>public MutableBag<K> toBag()
RichIterabletoBag in interface RichIterable<K>public <NK,NV> MutableMap<NK,NV> toMap(Function<? super K,? extends NK> keyFunction, Function<? super K,? extends NV> valueFunction)
RichIterabletoMap in interface RichIterable<K>public <NK,NV> MutableSortedMap<NK,NV> toSortedMap(Function<? super K,? extends NK> keyFunction, Function<? super K,? extends NV> valueFunction)
RichIterabletoSortedMap in interface RichIterable<K>public <NK,NV> MutableSortedMap<NK,NV> toSortedMap(Comparator<? super NK> comparator, Function<? super K,? extends NK> keyFunction, Function<? super K,? extends NV> valueFunction)
RichIterabletoSortedMap in interface RichIterable<K>public LazyIterable<K> asLazy()
RichIterableasLazy in interface RichIterable<K>public MutableSet<K> asUnmodifiable()
MutableSetasUnmodifiable in interface MutableCollection<K>asUnmodifiable in interface MutableSet<K>public MutableSet<K> asSynchronized()
MutableCollection
MutableCollection collection = myCollection.asSynchronized();
...
synchronized(collection)
{
Iterator i = c.iterator(); // Must be in the synchronized block
while (i.hasNext())
foo(i.next());
}
Failure to follow this advice may result in non-deterministic behavior.
The preferred way of iterating over a synchronized collection is to use the collection.forEach() method which is
properly synchronized internally.
MutableCollection collection = myCollection.asSynchronized();
...
collection.forEach(new Procedure()
{
public void value(Object each)
{
...
}
});
The returned collection does not pass the hashCode and equals operations through to the
backing collection, but relies on Object's equals and hashCode methods. This is necessary to preserve
the contracts of these operations in the case that the backing collection is a set or a list.
The returned collection will be serializable if this collection is serializable.asSynchronized in interface MutableCollection<K>asSynchronized in interface MutableSet<K>public ImmutableSet<K> toImmutable()
MutableSettoImmutable in interface MutableCollection<K>toImmutable in interface MutableSet<K>toImmutable in interface UnsortedSetIterable<K>public boolean notEmpty()
RichIterablenotEmpty in interface RichIterable<K>public boolean isEmpty()
RichIterableisEmpty in interface RichIterable<K>isEmpty in interface Collection<K>isEmpty in interface Set<K>public UnifiedSetWithHashingStrategy<K> with(K element)
MutableCollectionMutableCollectionIn the case oflist; list = list.with("1"); list = list.with("2"); return list;
FixedSizeCollection a new instance of MutableCollection will be returned by with, and any
variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling add on itself.with in interface MutableCollection<K>with in interface MutableSet<K>Collection.add(Object)public UnifiedSetWithHashingStrategy<K> with(K element1, K element2)
public UnifiedSetWithHashingStrategy<K> with(K element1, K element2, K element3)
public UnifiedSetWithHashingStrategy<K> with(K... elements)
public UnifiedSetWithHashingStrategy<K> withAll(Iterable<? extends K> iterable)
MutableCollectionMutableCollectionIn the case oflist; list = list.withAll(FastList.newListWith("1", "2")); return list;
FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling addAll on itself.withAll in interface MutableCollection<K>withAll in interface MutableSet<K>Collection.addAll(Collection)public UnifiedSetWithHashingStrategy<K> without(K element)
MutableCollectionMutableCollectionIn the case oflist; list = list.without("1"); list = list.without("2"); return list;
FixedSizeCollection a new instance of MutableCollection will be returned by without, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling remove on itself.without in interface MutableCollection<K>without in interface MutableSet<K>Collection.remove(Object)public UnifiedSetWithHashingStrategy<K> withoutAll(Iterable<? extends K> elements)
MutableCollectionMutableCollectionIn the case oflist; list = list.withoutAll(FastList.newListWith("1", "2")); return list;
FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll,
and any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling removeAll on itself.withoutAll in interface MutableCollection<K>withoutAll in interface MutableSet<K>Collection.removeAll(Collection)public boolean addAll(Collection<? extends K> collection)
public boolean addAllIterable(Iterable<? extends K> iterable)
addAllIterable in interface MutableCollection<K>Collection.addAll(Collection)public boolean remove(Object key)
public int size()
RichIterablesize in interface RichIterable<K>size in interface Pool<K>size in interface BatchIterable<K>size in interface Collection<K>size in interface Set<K>public boolean equals(Object object)
SetIterableSet.equals(Object).public int hashCode()
SetIterableSet.hashCode().public String toString()
RichIterableString.valueOf(Object).toString in interface RichIterable<K>toString in class Objectpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic boolean containsAll(Collection<?> collection)
RichIterablecontainsAll in interface RichIterable<K>containsAll in interface Collection<K>containsAll in interface Set<K>Collection.containsAll(Collection)public boolean containsAllIterable(Iterable<?> source)
RichIterablecontainsAllIterable in interface RichIterable<K>public boolean containsAllArguments(Object... elements)
RichIterablecontainsAllArguments in interface RichIterable<K>public boolean removeAll(Collection<?> collection)
public boolean removeAllIterable(Iterable<?> iterable)
removeAllIterable in interface MutableCollection<K>Collection.removeAll(Collection)public boolean retainAll(Collection<?> collection)
public boolean retainAllIterable(Iterable<?> iterable)
retainAllIterable in interface MutableCollection<K>Collection.retainAll(Collection)public UnifiedSetWithHashingStrategy<K> clone()
clone in interface MutableSet<K>clone in class Objectpublic Object[] toArray()
RichIterabletoArray in interface RichIterable<K>toArray in interface Collection<K>toArray in interface Set<K>Collection.toArray()public <T> T[] toArray(T[] array)
RichIterabletoArray in interface RichIterable<K>toArray in interface Collection<K>toArray in interface Set<K>Collection.toArray(Object[])public String makeString()
RichIterableRichIterable.makeString(String) and defaulting
the separator parameter to the characters ", " (comma and space).makeString in interface RichIterable<K>public String makeString(String separator)
RichIterableRichIterable.makeString(String, String, String)
and defaulting the start and end parameters to "" (the empty String).makeString in interface RichIterable<K>public String makeString(String start, String separator, String end)
RichIterablemakeString in interface RichIterable<K>public void appendString(Appendable appendable)
RichIterableAppendable. Prints the string returned
by RichIterable.makeString().appendString in interface RichIterable<K>public void appendString(Appendable appendable, String separator)
RichIterableAppendable. Prints the string returned
by RichIterable.makeString(String).appendString in interface RichIterable<K>public void appendString(Appendable appendable, String start, String separator, String end)
RichIterableAppendable. Prints the string returned
by RichIterable.makeString(String, String, String).appendString in interface RichIterable<K>public <V> UnifiedSetWithHashingStrategyMultimap<V,K> groupBy(Function<? super K,? extends V> function)
RichIterablee.g.
return people.groupBy(new Function<Person, String>()
{
public String value(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
});
groupBy in interface MutableCollection<K>groupBy in interface RichIterable<K>groupBy in interface MutableSet<K>groupBy in interface UnsortedSetIterable<K>public <V,R extends MutableMultimap<V,K>> R groupBy(Function<? super K,? extends V> function, R target)
RichIterableRichIterable.groupBy(Function), except that the results are gathered into the specified target
multimap.
e.g.
return people.groupBy(new Function<Person, String>()
{
public String value(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
}, new FastListMultimap<String, Person>());
groupBy in interface RichIterable<K>public <V> UnifiedSetMultimap<V,K> groupByEach(Function<? super K,? extends Iterable<V>> function)
RichIterableRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
for each value.groupByEach in interface MutableCollection<K>groupByEach in interface RichIterable<K>groupByEach in interface MutableSet<K>groupByEach in interface UnsortedSetIterable<K>public <V,R extends MutableMultimap<V,K>> R groupByEach(Function<? super K,? extends Iterable<V>> function, R target)
RichIterableRichIterable.groupByEach(Function), except that the results are gathered into the specified target
multimap.groupByEach in interface RichIterable<K>public <V> MutableMap<V,K> groupByUniqueKey(Function<? super K,? extends V> function)
RichIterablegroupByUniqueKey in interface MutableCollection<K>groupByUniqueKey in interface RichIterable<K>RichIterable.groupBy(Function)public <S> MutableSet<Pair<K,S>> zip(Iterable<S> that)
RichIterableRichIterable formed from this RichIterable and another RichIterable by
combining corresponding elements in pairs. If one of the two RichIterables is longer than the other, its
remaining elements are ignored.zip in interface MutableCollection<K>zip in interface RichIterable<K>zip in interface MutableSet<K>zip in interface UnsortedSetIterable<K>S - the type of the second half of the returned pairsthat - The RichIterable providing the second half of each result pairRichIterable containing pairs consisting of corresponding elements of this RichIterable and that. The length of the returned RichIterable is the minimum of the lengths of
this RichIterable and that.public <S,R extends Collection<Pair<K,S>>> R zip(Iterable<S> that, R target)
RichIterableRichIterable.zip(Iterable) but uses target for output.zip in interface RichIterable<K>public MutableSet<Pair<K,Integer>> zipWithIndex()
RichIterableRichIterable with its indices.zipWithIndex in interface MutableCollection<K>zipWithIndex in interface RichIterable<K>zipWithIndex in interface MutableSet<K>zipWithIndex in interface SetIterable<K>zipWithIndex in interface UnsortedSetIterable<K>RichIterable containing pairs consisting of all elements of this RichIterable
paired with their index. Indices start at 0.RichIterable.zip(Iterable)public <R extends Collection<Pair<K,Integer>>> R zipWithIndex(R target)
RichIterableRichIterable.zipWithIndex() but uses target for output.zipWithIndex in interface RichIterable<K>public RichIterable<RichIterable<K>> chunk(int size)
RichIterablechunk in interface RichIterable<K>size - the number of elements per chunkRichIterable containing RichIterables of size size, except the last will be
truncated if the elements don't divide evenly.public MutableSet<K> union(SetIterable<? extends K> set)
SetIterablethis 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.union in interface MutableSet<K>union in interface SetIterable<K>union in interface UnsortedSetIterable<K>public <R extends Set<K>> R unionInto(SetIterable<? extends K> set, R targetSet)
SetIterableSetIterable.union(SetIterable) but adds all the objects to targetSet and returns it.unionInto in interface SetIterable<K>public MutableSet<K> intersect(SetIterable<? extends K> set)
SetIterablethis 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.intersect in interface MutableSet<K>intersect in interface SetIterable<K>intersect in interface UnsortedSetIterable<K>public <R extends Set<K>> R intersectInto(SetIterable<? extends K> set, R targetSet)
SetIterableSetIterable.intersect(SetIterable) but adds all the objects to targetSet and returns it.intersectInto in interface SetIterable<K>public MutableSet<K> difference(SetIterable<? extends K> subtrahendSet)
SetIterablethis that are not members of subtrahendSet. The difference of
[1, 2, 3] and [2, 3, 4] is [1].difference in interface MutableSet<K>difference in interface SetIterable<K>difference in interface UnsortedSetIterable<K>public <R extends Set<K>> R differenceInto(SetIterable<? extends K> subtrahendSet, R targetSet)
SetIterableSetIterable.difference(SetIterable) but adds all the objects to targetSet and returns it.differenceInto in interface SetIterable<K>public MutableSet<K> symmetricDifference(SetIterable<? extends K> setB)
SetIterablethis 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.symmetricDifference in interface MutableSet<K>symmetricDifference in interface SetIterable<K>symmetricDifference in interface UnsortedSetIterable<K>public <R extends Set<K>> R symmetricDifferenceInto(SetIterable<? extends K> set, R targetSet)
SetIterableSetIterable.symmetricDifference(SetIterable) but adds all the objects to targetSet and returns it.symmetricDifferenceInto in interface SetIterable<K>public boolean isSubsetOf(SetIterable<? extends K> candidateSuperset)
SetIterablethis are also members of candidateSuperset.
For example, [1, 2] is a subset of [1, 2, 3], but [1, 4] is not.isSubsetOf in interface SetIterable<K>public boolean isProperSubsetOf(SetIterable<? extends K> candidateSuperset)
SetIterablethis 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.isProperSubsetOf in interface SetIterable<K>public MutableSet<UnsortedSetIterable<K>> powerSet()
UnsortedSetIterablethis. For example, the powerset of [1, 2] is
[[], [1], [2], [1, 2]].powerSet in interface MutableSet<K>powerSet in interface UnsortedSetIterable<K>public <B> LazyIterable<Pair<K,B>> cartesianProduct(SetIterable<B> set)
SetIterablethis and b is a
member of set.cartesianProduct in interface SetIterable<K>public K get(K key)
Poolkey.public K put(K key)
Poolkey into the pool. If there is no existing object that is equal
to key, key will be added to the pool and the return value will be the same instance.
If there is an existing object in the pool that is equal to key, the pool will remain unchanged
and the pooled instance will be is returned.public K removeFromPool(K key)
Poolkey and removes it.removeFromPool in interface Pool<K>key - object to removepublic <K2,V> MutableMap<K2,V> aggregateInPlaceBy(Function<? super K,? extends K2> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super K> mutatingAggregator)
RichIterableaggregateInPlaceBy in interface MutableCollection<K>aggregateInPlaceBy in interface RichIterable<K>public <K2,V> MutableMap<K2,V> aggregateBy(Function<? super K,? extends K2> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super K,? extends V> nonMutatingAggregator)
RichIterableaggregateBy in interface MutableCollection<K>aggregateBy in interface RichIterable<K>Copyright © 2004–2017. All rights reserved.