public class TreeBag<T> extends AbstractMutableBag<T> implements java.io.Externalizable, com.gs.collections.api.bag.sorted.MutableSortedBag<T>
| Constructor and Description |
|---|
TreeBag() |
TreeBag(java.util.Comparator<? super T> comparator) |
TreeBag(java.util.Comparator<? super T> comparator,
java.lang.Iterable<? extends T> iterable) |
TreeBag(com.gs.collections.api.bag.sorted.SortedBag<T> sortedBag) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T item) |
void |
addOccurrences(T item,
int occurrences) |
boolean |
allSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.
|
<P> boolean |
allSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for every element of the collection, or returns false.
|
boolean |
anySatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
com.gs.collections.api.bag.sorted.ParallelSortedBag<T> |
asParallel(java.util.concurrent.ExecutorService executorService,
int batchSize) |
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
asSynchronized()
Returns a synchronized (thread-safe) collection backed by this collection.
|
UnmodifiableSortedBag<T> |
asUnmodifiable()
Returns an unmodifiable view of the set.
|
void |
clear() |
TreeBag<T> |
clone() |
<V> com.gs.collections.api.list.MutableList<V> |
collect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Returns a new collection with the results of applying the specified function on each element of the source
collection.
|
com.gs.collections.api.list.primitive.MutableBooleanList |
collectBoolean(com.gs.collections.api.block.function.primitive.BooleanFunction<? super T> booleanFunction)
Returns a new primitive
boolean iterable with the results of applying the specified function on each element
of the source collection. |
com.gs.collections.api.list.primitive.MutableByteList |
collectByte(com.gs.collections.api.block.function.primitive.ByteFunction<? super T> byteFunction)
Returns a new primitive
byte iterable with the results of applying the specified function on each element
of the source collection. |
com.gs.collections.api.list.primitive.MutableCharList |
collectChar(com.gs.collections.api.block.function.primitive.CharFunction<? super T> charFunction)
Returns a new primitive
char iterable with the results of applying the specified function on each element
of the source collection. |
com.gs.collections.api.list.primitive.MutableDoubleList |
collectDouble(com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> doubleFunction)
Returns a new primitive
double iterable with the results of applying the specified function on each element
of the source collection. |
com.gs.collections.api.list.primitive.MutableFloatList |
collectFloat(com.gs.collections.api.block.function.primitive.FloatFunction<? super T> floatFunction)
Returns a new primitive
float iterable with the results of applying the specified function on each element
of the source collection. |
<V> com.gs.collections.api.list.MutableList<V> |
collectIf(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,? 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.
|
com.gs.collections.api.list.primitive.MutableIntList |
collectInt(com.gs.collections.api.block.function.primitive.IntFunction<? super T> intFunction)
Returns a new primitive
int iterable with the results of applying the specified function on each element
of the source collection. |
com.gs.collections.api.list.primitive.MutableLongList |
collectLong(com.gs.collections.api.block.function.primitive.LongFunction<? super T> longFunction)
Returns a new primitive
long iterable with the results of applying the specified function on each element
of the source collection. |
com.gs.collections.api.list.primitive.MutableShortList |
collectShort(com.gs.collections.api.block.function.primitive.ShortFunction<? super T> shortFunction)
Returns a new primitive
short iterable with the results of applying the specified function on each element
of the source collection. |
<P,V> com.gs.collections.api.list.MutableList<V> |
collectWith(com.gs.collections.api.block.function.Function2<? super T,? super P,? extends V> function,
P parameter)
Same as collect with a
Function2 and specified parameter which is passed to the block
|
java.util.Comparator<? super T> |
comparator()
Returns the comparator used to order the elements in this bag, or null if this bag uses the natural ordering of
its elements.
|
int |
compareTo(com.gs.collections.api.bag.sorted.SortedBag<T> otherBag) |
boolean |
contains(java.lang.Object o)
Returns true if the iterable has an element which responds true to element.equals(object).
|
int |
count(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Return the total number of elements that answer true to the specified predicate.
|
<P> int |
countWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns the total number of elements that evaluate to true for the specified predicate.
|
T |
detect(com.gs.collections.api.block.predicate.Predicate<? super T> 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.
|
T |
detectIfNone(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function0<? extends T> function)
Returns the first element of the iterable for which the predicate evaluates to true.
|
<P> T |
detectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? 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> T |
detectWithIfNone(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter,
com.gs.collections.api.block.function.Function0<? extends T> 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.
|
com.gs.collections.api.set.sorted.MutableSortedSet<T> |
distinct()
Returns a new
SortedIterable containing the distinct elements in this iterable. |
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
dropWhile(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns the final elements that do not satisfy the Predicate.
|
boolean |
equals(java.lang.Object other)
Two bagsb1 and b2 are equal if m1.toMapOfItemToCount().equals(m2.toMapOfItemToCount()).
|
<V> com.gs.collections.api.list.MutableList<V> |
flatCollect(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function)
flatCollect is a special case of RichIterable.collect(Function). |
void |
forEach(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.
|
<P> void |
forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super T,? 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(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure
|
void |
forEachWithOccurrences(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> procedure)
For each distinct item, with the number of occurrences, execute the specified procedure.
|
T |
getFirst()
Returns the first element of an iterable.
|
T |
getLast()
Returns the last element of an iterable.
|
<V> TreeBagMultimap<V,T> |
groupBy(com.gs.collections.api.block.function.Function<? super T,? 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 com.gs.collections.api.multimap.MutableMultimap<V,T>> |
groupBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function,
R target)
Same as
RichIterable.groupBy(Function), except that the results are gathered into the specified target
multimap. |
<V> TreeBagMultimap<V,T> |
groupByEach(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.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 com.gs.collections.api.multimap.MutableMultimap<V,T>> |
groupByEach(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function,
R target)
Same as
RichIterable.groupByEach(Function), except that the results are gathered into the specified target
multimap. |
<V> com.gs.collections.api.map.MutableMap<V,T> |
groupByUniqueKey(com.gs.collections.api.block.function.Function<? super T,? 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()
Returns the hash code for this Bag, defined as this.
Bag.toMapOfItemToCount().hashCode(). |
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
java.util.Iterator<T> |
iterator() |
T |
max()
Returns the maximum element out of this container based on the natural order.
|
T |
max(java.util.Comparator<? super T> comparator)
Returns the maximum element out of this container based on the comparator.
|
<V extends java.lang.Comparable<? super V>> |
maxBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.
|
T |
min()
Returns the minimum element out of this container based on the natural order.
|
T |
min(java.util.Comparator<? super T> comparator)
Returns the minimum element out of this container based on the comparator.
|
<V extends java.lang.Comparable<? super V>> |
minBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.
|
static <E> TreeBag<E> |
newBag() |
static <E> TreeBag<E> |
newBag(java.util.Comparator<? super E> comparator) |
static <E> TreeBag<E> |
newBag(java.util.Comparator<? super E> comparator,
java.lang.Iterable<? extends E> iterable) |
static <E> TreeBag<E> |
newBag(java.lang.Iterable<? extends E> source) |
static <E> TreeBag<E> |
newBagWith(java.util.Comparator<? super E> comparator,
E... elements) |
static <E> TreeBag<E> |
newBagWith(E... elements) |
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
newEmpty()
Creates a new empty mutable version of the same collection type.
|
boolean |
noneSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.
|
<P> boolean |
noneSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
int |
occurrencesOf(java.lang.Object item)
The occurrences of a distinct item in the bag.
|
com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag<T> |
partition(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag<T> |
partitionWhile(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.
|
<P> com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag<T> |
partitionWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Filters a collection into a PartitionIterable based on the evaluation of the predicate.
|
void |
readExternal(java.io.ObjectInput in) |
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.
|
<R extends java.util.Collection<T>> |
reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target)
Same as the reject method with one parameter but uses the specified target collection for the results.
|
<P> com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
rejectWith(com.gs.collections.api.block.predicate.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. |
<P,R extends java.util.Collection<T>> |
rejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter,
R target)
Similar to
RichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2. |
boolean |
remove(java.lang.Object item) |
boolean |
removeAll(java.util.Collection<?> collection) |
boolean |
removeAllIterable(java.lang.Iterable<?> iterable) |
void |
removeIf(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Removes all elements in the collection that evaluate to true for the specified predicate.
|
<P> void |
removeIfWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.
|
boolean |
removeOccurrences(java.lang.Object item,
int occurrences) |
boolean |
retainAll(java.util.Collection<?> collection) |
boolean |
retainAllIterable(java.lang.Iterable<?> iterable) |
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns all elements of the source collection that return true when evaluating the predicate.
|
<R extends java.util.Collection<T>> |
select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
R target)
Same as the select method with one parameter but uses the specified target collection for the results.
|
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
selectByOccurrences(com.gs.collections.api.block.predicate.primitive.IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.
|
<S> com.gs.collections.api.bag.sorted.MutableSortedBag<S> |
selectInstancesOf(java.lang.Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz. |
<P> com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
selectWith(com.gs.collections.api.block.predicate.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. |
<P,R extends java.util.Collection<T>> |
selectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter,
R target)
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.
|
int |
sizeDistinct()
The size of the Bag when counting only distinct elements.
|
double |
sumOfDouble(com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> function)
Returns the final double result of evaluating function for each element of the iterable and adding the results
together.
|
double |
sumOfFloat(com.gs.collections.api.block.function.primitive.FloatFunction<? super T> function)
Returns the final double result of evaluating function for each element of the iterable and adding the results
together.
|
long |
sumOfInt(com.gs.collections.api.block.function.primitive.IntFunction<? super T> function)
Returns the final long result of evaluating function for each element of the iterable and adding the results
together.
|
long |
sumOfLong(com.gs.collections.api.block.function.primitive.LongFunction<? super T> function)
Returns the final long result of evaluating function for each element of the iterable and adding the results
together.
|
com.gs.collections.api.bag.sorted.MutableSortedBag<T> |
takeWhile(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns the initial elements that satisfy the Predicate.
|
com.gs.collections.api.bag.MutableBag<T> |
toBag()
Converts the collection to the default MutableBag implementation.
|
com.gs.collections.api.bag.sorted.ImmutableSortedBag<T> |
toImmutable()
Convert the SortedBag to an ImmutableSortedBag.
|
com.gs.collections.api.list.MutableList<T> |
toList()
Converts the collection to a MutableList implementation.
|
com.gs.collections.api.map.sorted.MutableSortedMap<T,java.lang.Integer> |
toMapOfItemToCount()
Converts the Bag to a Map of the Item type to its count as an Integer.
|
com.gs.collections.api.set.MutableSet<T> |
toSet()
Converts the collection to a MutableSet implementation.
|
com.gs.collections.api.stack.MutableStack<T> |
toStack()
Converts the SortedIterable to a mutable MutableStack implementation.
|
java.lang.String |
toStringOfItemToCount()
Returns a string representation of this bag.
|
TreeBag<T> |
with(T... elements) |
TreeBag<T> |
with(T element)
This method allows mutable and fixed size collections the ability to add elements to their existing elements.
|
TreeBag<T> |
with(T element1,
T element2) |
TreeBag<T> |
with(T element1,
T element2,
T element3) |
TreeBag<T> |
withAll(java.lang.Iterable<? extends T> iterable)
This method allows mutable and fixed size collections the ability to add multiple elements to their existing
elements.
|
TreeBag<T> |
without(T element)
This method allows mutable and fixed size collections the ability to remove elements from their existing elements.
|
TreeBag<T> |
withoutAll(java.lang.Iterable<? extends T> iterable)
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing
elements.
|
void |
writeExternal(java.io.ObjectOutput out) |
<S> com.gs.collections.api.list.MutableList<com.gs.collections.api.tuple.Pair<T,S>> |
zip(java.lang.Iterable<S> that)
Returns a
RichIterable formed from this RichIterable and another RichIterable by
combining corresponding elements in pairs. |
com.gs.collections.api.set.sorted.MutableSortedSet<com.gs.collections.api.tuple.Pair<T,java.lang.Integer>> |
zipWithIndex()
Zips this
RichIterable with its indices. |
collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShortaddAll, addAllIterable, aggregateBy, aggregateInPlaceBy, chunk, injectIntoWith, selectAndRejectWithappendString, appendString, appendString, asLazy, collect, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, flatCollect, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, notEmpty, toArray, toArray, toMap, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexfinalize, getClass, notify, notifyAll, wait, wait, waitaggregateBy, aggregateInPlaceByappendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, flatCollect, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, notEmpty, toArray, toArray, toMap, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexpublic TreeBag()
public TreeBag(java.util.Comparator<? super T> comparator)
public TreeBag(com.gs.collections.api.bag.sorted.SortedBag<T> sortedBag)
public static <E> TreeBag<E> newBag()
public static <E> TreeBag<E> newBag(java.util.Comparator<? super E> comparator)
public static <E> TreeBag<E> newBag(java.lang.Iterable<? extends E> source)
public static <E> TreeBag<E> newBag(java.util.Comparator<? super E> comparator, java.lang.Iterable<? extends E> iterable)
public static <E> TreeBag<E> newBagWith(E... elements)
public static <E> TreeBag<E> newBagWith(java.util.Comparator<? super E> comparator, E... elements)
public TreeBag<T> clone()
clone in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>clone in class java.lang.Objectpublic boolean equals(java.lang.Object other)
com.gs.collections.api.bag.Bagpublic int sizeDistinct()
com.gs.collections.api.bag.BagsizeDistinct in interface com.gs.collections.api.bag.Bag<T>public int hashCode()
com.gs.collections.api.bag.BagBag.toMapOfItemToCount().hashCode().public void forEachWithOccurrences(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> procedure)
com.gs.collections.api.bag.BagforEachWithOccurrences in interface com.gs.collections.api.bag.Bag<T>forEachWithOccurrences in class AbstractMutableBag<T>public com.gs.collections.api.bag.sorted.MutableSortedBag<T> selectByOccurrences(com.gs.collections.api.block.predicate.primitive.IntPredicate predicate)
com.gs.collections.api.bag.Bagpublic int occurrencesOf(java.lang.Object item)
com.gs.collections.api.bag.BagoccurrencesOf in interface com.gs.collections.api.bag.Bag<T>public com.gs.collections.api.map.sorted.MutableSortedMap<T,java.lang.Integer> toMapOfItemToCount()
com.gs.collections.api.bag.Bagpublic java.lang.String toStringOfItemToCount()
com.gs.collections.api.bag.BagBag.forEachWithOccurrences(ObjectIntProcedure)
and Iterable.iterator(). The element-count mappings are enclosed in braces ("{}"). Adjacent mappings are
separated by the characters ", " (comma and space). Each element-count mapping is rendered as the element
followed by an equals sign ("=") followed by the number of ooccurrences. Elements and are converted to
strings as by String.valueOf(Object).
The string representation is similar to AbstractMap.toString(), not RichIterable.toString().toStringOfItemToCount in interface com.gs.collections.api.bag.Bag<T>public boolean isEmpty()
com.gs.collections.api.RichIterableisEmpty in interface com.gs.collections.api.RichIterable<T>isEmpty in interface java.util.Collection<T>isEmpty in class AbstractRichIterable<T>public boolean remove(java.lang.Object item)
remove in interface java.util.Collection<T>remove in class AbstractMutableCollection<T>public boolean removeAll(java.util.Collection<?> collection)
removeAll in interface java.util.Collection<T>removeAll in class AbstractMutableCollection<T>public boolean retainAll(java.util.Collection<?> collection)
retainAll in interface java.util.Collection<T>retainAll in class AbstractMutableCollection<T>public void clear()
clear in interface java.util.Collection<T>public boolean contains(java.lang.Object o)
com.gs.collections.api.RichIterablecontains in interface com.gs.collections.api.RichIterable<T>contains in interface java.util.Collection<T>contains in class AbstractRichIterable<T>public int compareTo(com.gs.collections.api.bag.sorted.SortedBag<T> otherBag)
compareTo in interface java.lang.Comparable<com.gs.collections.api.bag.sorted.SortedBag<T>>public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void forEach(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
com.gs.collections.api.InternalIterablee.g. people.forEach(new Procedure() { public void value(Person person) { LOGGER.info(person.getName()); } });
forEach in interface com.gs.collections.api.InternalIterable<T>public void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> objectIntProcedure)
com.gs.collections.api.InternalIterablee.g. people.forEachWithIndex(new ObjectIntProcedure() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex in interface com.gs.collections.api.InternalIterable<T>forEachWithIndex in class AbstractRichIterable<T>public <P> void forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super T,? super P> procedure, P parameter)
com.gs.collections.api.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 com.gs.collections.api.InternalIterable<T>forEachWith in class AbstractRichIterable<T>public java.util.Iterator<T> iterator()
public void addOccurrences(T item, int occurrences)
addOccurrences in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>public boolean removeOccurrences(java.lang.Object item,
int occurrences)
removeOccurrences in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>public TreeBag<T> without(T element)
com.gs.collections.api.collection.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.public TreeBag<T> withAll(java.lang.Iterable<? extends T> iterable)
com.gs.collections.api.collection.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.public TreeBag<T> withoutAll(java.lang.Iterable<? extends T> iterable)
com.gs.collections.api.collection.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.public com.gs.collections.api.bag.sorted.ImmutableSortedBag<T> toImmutable()
com.gs.collections.api.bag.sorted.SortedBagpublic <P,V> com.gs.collections.api.list.MutableList<V> collectWith(com.gs.collections.api.block.function.Function2<? super T,? super P,? extends V> function, P parameter)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectWith in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectWith in interface com.gs.collections.api.collection.MutableCollection<T>collectWith in interface com.gs.collections.api.RichIterable<T>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 TreeBag<T> with(T element)
com.gs.collections.api.collection.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.public com.gs.collections.api.bag.sorted.MutableSortedBag<T> newEmpty()
com.gs.collections.api.collection.MutableCollectionpublic <P> com.gs.collections.api.bag.sorted.MutableSortedBag<T> selectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.selectWith in interface com.gs.collections.api.bag.Bag<T>selectWith in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>selectWith in interface com.gs.collections.api.bag.sorted.SortedBag<T>selectWith in interface com.gs.collections.api.collection.MutableCollection<T>selectWith in interface com.gs.collections.api.ordered.SortedIterable<T>selectWith in interface com.gs.collections.api.RichIterable<T>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> com.gs.collections.api.bag.sorted.MutableSortedBag<T> rejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.rejectWith in interface com.gs.collections.api.bag.Bag<T>rejectWith in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>rejectWith in interface com.gs.collections.api.bag.sorted.SortedBag<T>rejectWith in interface com.gs.collections.api.collection.MutableCollection<T>rejectWith in interface com.gs.collections.api.ordered.SortedIterable<T>rejectWith in interface com.gs.collections.api.RichIterable<T>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 void removeIf(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.collection.MutableCollectione.g. return lastNames.removeIf(Predicates.isNull());
removeIf in interface com.gs.collections.api.collection.MutableCollection<T>removeIf in class AbstractMutableCollection<T>public <P> void removeIfWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.collection.MutableCollectione.g. return lastNames.removeIfWith(PredicatesLite.isNull(), null);
removeIfWith in interface com.gs.collections.api.collection.MutableCollection<T>removeIfWith in class AbstractMutableCollection<T>public <P> T detectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>detectWith in class AbstractRichIterable<T>public <P> T detectWithIfNone(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter, com.gs.collections.api.block.function.Function0<? extends T> function)
com.gs.collections.api.RichIterabledetectWithIfNone in interface com.gs.collections.api.RichIterable<T>detectWithIfNone in class AbstractRichIterable<T>public <P> int countWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterablee.g. return lastNames.countWith(PredicatesLite.equal(), "Smith");
countWith in interface com.gs.collections.api.RichIterable<T>countWith in class AbstractRichIterable<T>public <P> boolean anySatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableanySatisfyWith in interface com.gs.collections.api.RichIterable<T>anySatisfyWith in class AbstractRichIterable<T>public <P> boolean allSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableallSatisfyWith in interface com.gs.collections.api.RichIterable<T>allSatisfyWith in class AbstractRichIterable<T>public <P> boolean noneSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterablenoneSatisfyWith in interface com.gs.collections.api.RichIterable<T>noneSatisfyWith in class AbstractRichIterable<T>public UnmodifiableSortedBag<T> asUnmodifiable()
com.gs.collections.api.bag.sorted.MutableSortedBagpublic com.gs.collections.api.bag.sorted.MutableSortedBag<T> asSynchronized()
com.gs.collections.api.collection.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.public com.gs.collections.api.bag.sorted.ParallelSortedBag<T> asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
public boolean removeAllIterable(java.lang.Iterable<?> iterable)
removeAllIterable in interface com.gs.collections.api.collection.MutableCollection<T>removeAllIterable in class AbstractMutableCollection<T>Collection.removeAll(Collection)public boolean retainAllIterable(java.lang.Iterable<?> iterable)
retainAllIterable in interface com.gs.collections.api.collection.MutableCollection<T>retainAllIterable in class AbstractMutableCollection<T>Collection.retainAll(Collection)public int size()
com.gs.collections.api.RichIterablepublic com.gs.collections.api.bag.sorted.MutableSortedBag<T> reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.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 com.gs.collections.api.bag.Bag<T>reject in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>reject in interface com.gs.collections.api.bag.sorted.SortedBag<T>reject in interface com.gs.collections.api.collection.MutableCollection<T>reject in interface com.gs.collections.api.ordered.SortedIterable<T>reject in interface com.gs.collections.api.RichIterable<T>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag<T> partition(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterablee.g.
return people.partition(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.getAddress().getState().getName().equals("New York");
}
});
partition in interface com.gs.collections.api.bag.Bag<T>partition in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>partition in interface com.gs.collections.api.bag.sorted.SortedBag<T>partition in interface com.gs.collections.api.collection.MutableCollection<T>partition in interface com.gs.collections.api.ordered.SortedIterable<T>partition in interface com.gs.collections.api.RichIterable<T>public <P> com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag<T> partitionWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.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 com.gs.collections.api.bag.Bag<T>partitionWith in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>partitionWith in interface com.gs.collections.api.bag.sorted.SortedBag<T>partitionWith in interface com.gs.collections.api.collection.MutableCollection<T>partitionWith in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag<T> partitionWhile(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.ordered.SortedIterablepublic <S> com.gs.collections.api.bag.sorted.MutableSortedBag<S> selectInstancesOf(java.lang.Class<S> clazz)
com.gs.collections.api.RichIterableclazz.selectInstancesOf in interface com.gs.collections.api.bag.Bag<T>selectInstancesOf in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>selectInstancesOf in interface com.gs.collections.api.bag.sorted.SortedBag<T>selectInstancesOf in interface com.gs.collections.api.collection.MutableCollection<T>selectInstancesOf in interface com.gs.collections.api.ordered.SortedIterable<T>selectInstancesOf in interface com.gs.collections.api.RichIterable<T>public <V> TreeBagMultimap<V,T> groupBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablee.g.
return people.groupBy(new Function<Person, String>()
{
public String value(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
});
groupBy in interface com.gs.collections.api.bag.Bag<T>groupBy in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>groupBy in interface com.gs.collections.api.bag.sorted.SortedBag<T>groupBy in interface com.gs.collections.api.collection.MutableCollection<T>groupBy in interface com.gs.collections.api.ordered.SortedIterable<T>groupBy in interface com.gs.collections.api.RichIterable<T>public <V> TreeBagMultimap<V,T> groupByEach(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function)
com.gs.collections.api.RichIterableRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
for each value.groupByEach in interface com.gs.collections.api.bag.Bag<T>groupByEach in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>groupByEach in interface com.gs.collections.api.bag.sorted.SortedBag<T>groupByEach in interface com.gs.collections.api.collection.MutableCollection<T>groupByEach in interface com.gs.collections.api.ordered.SortedIterable<T>groupByEach in interface com.gs.collections.api.RichIterable<T>public <V> com.gs.collections.api.map.MutableMap<V,T> groupByUniqueKey(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablepublic com.gs.collections.api.list.primitive.MutableByteList collectByte(com.gs.collections.api.block.function.primitive.ByteFunction<? super T> byteFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectByte in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectByte in interface com.gs.collections.api.collection.MutableCollection<T>collectByte in interface com.gs.collections.api.RichIterable<T>public T getFirst()
com.gs.collections.api.RichIterablegetFirst in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.set.sorted.MutableSortedSet<com.gs.collections.api.tuple.Pair<T,java.lang.Integer>> zipWithIndex()
com.gs.collections.api.RichIterableRichIterable with its indices.zipWithIndex in interface com.gs.collections.api.bag.Bag<T>zipWithIndex in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>zipWithIndex in interface com.gs.collections.api.bag.sorted.SortedBag<T>zipWithIndex in interface com.gs.collections.api.collection.MutableCollection<T>zipWithIndex in interface com.gs.collections.api.ordered.SortedIterable<T>zipWithIndex in interface com.gs.collections.api.RichIterable<T>RichIterable containing pairs consisting of all elements of this RichIterable
paired with their index. Indices start at 0.RichIterable.zip(Iterable)public T getLast()
com.gs.collections.api.RichIterablegetLast in interface com.gs.collections.api.RichIterable<T>public <V> com.gs.collections.api.list.MutableList<V> collect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablee.g.
return people.collect(new Function<Person, String>()
{
public String valueOf(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
});
collect in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>collect in interface com.gs.collections.api.bag.sorted.SortedBag<T>collect in interface com.gs.collections.api.collection.MutableCollection<T>collect in interface com.gs.collections.api.RichIterable<T>public <V> com.gs.collections.api.list.MutableList<V> flatCollect(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>flatCollect in interface com.gs.collections.api.bag.sorted.SortedBag<T>flatCollect in interface com.gs.collections.api.collection.MutableCollection<T>flatCollect in interface com.gs.collections.api.RichIterable<T>function - The Function to applyfunctionpublic com.gs.collections.api.set.sorted.MutableSortedSet<T> distinct()
com.gs.collections.api.ordered.SortedIterableSortedIterable containing the distinct elements in this iterable.
Conceptually similar to RichIterable.toSet().RichIterable.toList() but retains the original order. If an element appears
multiple times in this iterable, the first one will be copied into the result.distinct in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>distinct in interface com.gs.collections.api.bag.sorted.SortedBag<T>distinct in interface com.gs.collections.api.ordered.SortedIterable<T>SortedIterable of distinct elementspublic com.gs.collections.api.bag.sorted.MutableSortedBag<T> takeWhile(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.ordered.SortedIterablepublic com.gs.collections.api.bag.sorted.MutableSortedBag<T> dropWhile(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.ordered.SortedIterablepublic <R extends java.util.Collection<T>> R select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, R target)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>select in class AbstractRichIterable<T>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,R extends java.util.Collection<T>> R selectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter, R target)
com.gs.collections.api.RichIterableRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.selectWith in interface com.gs.collections.api.RichIterable<T>selectWith in class AbstractRichIterable<T>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicatetarget - 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 com.gs.collections.api.bag.sorted.MutableSortedBag<T> select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterablee.g.
return people.select(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.getAddress().getCity().equals("Metuchen");
}
});
select in interface com.gs.collections.api.bag.Bag<T>select in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>select in interface com.gs.collections.api.bag.sorted.SortedBag<T>select in interface com.gs.collections.api.collection.MutableCollection<T>select in interface com.gs.collections.api.ordered.SortedIterable<T>select in interface com.gs.collections.api.RichIterable<T>public <R extends java.util.Collection<T>> R reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, R target)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>reject in class AbstractRichIterable<T>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,R extends java.util.Collection<T>> R rejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter, R target)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>rejectWith in class AbstractRichIterable<T>predicate - a Predicate2 to use as the reject criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicatetarget - 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 com.gs.collections.api.list.primitive.MutableBooleanList collectBoolean(com.gs.collections.api.block.function.primitive.BooleanFunction<? super T> booleanFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectBoolean in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectBoolean in interface com.gs.collections.api.collection.MutableCollection<T>collectBoolean in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.list.primitive.MutableCharList collectChar(com.gs.collections.api.block.function.primitive.CharFunction<? super T> charFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectChar in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectChar in interface com.gs.collections.api.collection.MutableCollection<T>collectChar in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.list.primitive.MutableDoubleList collectDouble(com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> doubleFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectDouble in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectDouble in interface com.gs.collections.api.collection.MutableCollection<T>collectDouble in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.list.primitive.MutableFloatList collectFloat(com.gs.collections.api.block.function.primitive.FloatFunction<? super T> floatFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectFloat in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectFloat in interface com.gs.collections.api.collection.MutableCollection<T>collectFloat in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.list.primitive.MutableIntList collectInt(com.gs.collections.api.block.function.primitive.IntFunction<? super T> intFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectInt in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectInt in interface com.gs.collections.api.collection.MutableCollection<T>collectInt in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.list.primitive.MutableLongList collectLong(com.gs.collections.api.block.function.primitive.LongFunction<? super T> longFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectLong in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectLong in interface com.gs.collections.api.collection.MutableCollection<T>collectLong in interface com.gs.collections.api.RichIterable<T>public com.gs.collections.api.list.primitive.MutableShortList collectShort(com.gs.collections.api.block.function.primitive.ShortFunction<? super T> shortFunction)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectShort in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectShort in interface com.gs.collections.api.collection.MutableCollection<T>collectShort in interface com.gs.collections.api.RichIterable<T>public <V> com.gs.collections.api.list.MutableList<V> collectIf(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablee.g. Lists.mutable.of().with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString())
collectIf in interface com.gs.collections.api.bag.sorted.MutableSortedBag<T>collectIf in interface com.gs.collections.api.bag.sorted.SortedBag<T>collectIf in interface com.gs.collections.api.collection.MutableCollection<T>collectIf in interface com.gs.collections.api.RichIterable<T>public <S> com.gs.collections.api.list.MutableList<com.gs.collections.api.tuple.Pair<T,S>> zip(java.lang.Iterable<S> that)
com.gs.collections.api.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 com.gs.collections.api.bag.sorted.MutableSortedBag<T>zip in interface com.gs.collections.api.collection.MutableCollection<T>zip in interface com.gs.collections.api.ordered.SortedIterable<T>zip in interface com.gs.collections.api.RichIterable<T>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 T detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>detect in class AbstractRichIterable<T>public T detectIfNone(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, com.gs.collections.api.block.function.Function0<? extends T> function)
com.gs.collections.api.RichIterabledetectIfNone in interface com.gs.collections.api.RichIterable<T>detectIfNone in class AbstractRichIterable<T>public int count(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterablee.g.
return people.count(new Predicate<Person>()
{
public boolean value(Person person)
{
return person.getAddress().getState().getName().equals("New York");
}
});
count in interface com.gs.collections.api.RichIterable<T>count in class AbstractRichIterable<T>public boolean anySatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableanySatisfy in interface com.gs.collections.api.RichIterable<T>anySatisfy in class AbstractRichIterable<T>public boolean allSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableallSatisfy in interface com.gs.collections.api.RichIterable<T>allSatisfy in class AbstractRichIterable<T>public boolean noneSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterablenoneSatisfy in interface com.gs.collections.api.RichIterable<T>noneSatisfy in class AbstractRichIterable<T>public com.gs.collections.api.list.MutableList<T> toList()
com.gs.collections.api.RichIterabletoList in interface com.gs.collections.api.RichIterable<T>toList in class AbstractRichIterable<T>public com.gs.collections.api.set.MutableSet<T> toSet()
com.gs.collections.api.RichIterabletoSet in interface com.gs.collections.api.RichIterable<T>toSet in class AbstractRichIterable<T>public com.gs.collections.api.bag.MutableBag<T> toBag()
com.gs.collections.api.RichIterabletoBag in interface com.gs.collections.api.RichIterable<T>toBag in class AbstractRichIterable<T>public com.gs.collections.api.stack.MutableStack<T> toStack()
com.gs.collections.api.ordered.SortedIterabletoStack in interface com.gs.collections.api.ordered.SortedIterable<T>public T min(java.util.Comparator<? super T> comparator)
com.gs.collections.api.RichIterablemin in interface com.gs.collections.api.RichIterable<T>min in class AbstractRichIterable<T>public T max(java.util.Comparator<? super T> comparator)
com.gs.collections.api.RichIterablemax in interface com.gs.collections.api.RichIterable<T>max in class AbstractRichIterable<T>public T min()
com.gs.collections.api.RichIterablepublic T max()
com.gs.collections.api.RichIterablepublic <V extends java.lang.Comparable<? super V>> T minBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterableminBy in interface com.gs.collections.api.RichIterable<T>minBy in class AbstractRichIterable<T>public <V extends java.lang.Comparable<? super V>> T maxBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablemaxBy in interface com.gs.collections.api.RichIterable<T>maxBy in class AbstractRichIterable<T>public long sumOfInt(com.gs.collections.api.block.function.primitive.IntFunction<? super T> function)
com.gs.collections.api.RichIterablesumOfInt in interface com.gs.collections.api.RichIterable<T>sumOfInt in class AbstractRichIterable<T>public double sumOfFloat(com.gs.collections.api.block.function.primitive.FloatFunction<? super T> function)
com.gs.collections.api.RichIterablesumOfFloat in interface com.gs.collections.api.RichIterable<T>sumOfFloat in class AbstractRichIterable<T>public long sumOfLong(com.gs.collections.api.block.function.primitive.LongFunction<? super T> function)
com.gs.collections.api.RichIterablesumOfLong in interface com.gs.collections.api.RichIterable<T>sumOfLong in class AbstractRichIterable<T>public double sumOfDouble(com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> function)
com.gs.collections.api.RichIterablesumOfDouble in interface com.gs.collections.api.RichIterable<T>sumOfDouble in class AbstractRichIterable<T>public <V,R extends com.gs.collections.api.multimap.MutableMultimap<V,T>> R groupBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function, R target)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>groupBy in class AbstractRichIterable<T>public <V,R extends com.gs.collections.api.multimap.MutableMultimap<V,T>> R groupByEach(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function, R target)
com.gs.collections.api.RichIterableRichIterable.groupByEach(Function), except that the results are gathered into the specified target
multimap.groupByEach in interface com.gs.collections.api.RichIterable<T>groupByEach in class AbstractRichIterable<T>public java.util.Comparator<? super T> comparator()
com.gs.collections.api.bag.sorted.SortedBagpublic boolean add(T item)
add in interface java.util.Collection<T>add in class AbstractMutableCollection<T>