Class AbstractBag<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Bag<T>,InternalIterable<T>,RichIterable<T>
- Direct Known Subclasses:
AbstractImmutableBagIterable,AbstractMutableBagIterable
- Since:
- 7.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V,R extends Collection<V>>
RSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.<R extends MutableBooleanCollection>
RcollectBoolean(BooleanFunction<? super T> booleanFunction, R target) Same asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableByteCollection>
RcollectByte(ByteFunction<? super T> byteFunction, R target) Same asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableCharCollection>
RcollectChar(CharFunction<? super T> charFunction, R target) Same asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableDoubleCollection>
RcollectDouble(DoubleFunction<? super T> doubleFunction, R target) Same asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableFloatCollection>
RcollectFloat(FloatFunction<? super T> floatFunction, R target) Same asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.<V,R extends Collection<V>>
RSame as the collectIf method with two parameters but uses the specified target collection for the results.<R extends MutableIntCollection>
RcollectInt(IntFunction<? super T> intFunction, R target) Same asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableLongCollection>
RcollectLong(LongFunction<? super T> longFunction, R target) Same asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableShortCollection>
RcollectShort(ShortFunction<? super T> shortFunction, R target) Same asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.<P,V, R extends Collection<V>>
RcollectWith(Function2<? super T, ? super P, ? extends V> function, P parameter, R target) Same as collectWith but with a targetCollection parameter to gather the results.intReturn the total number of elements that answer true to the specified predicate.<V,R extends Collection<V>>
RflatCollect(Function<? super T, ? extends Iterable<V>> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableBooleanCollection>
RflatCollectBoolean(Function<? super T, ? extends BooleanIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableByteCollection>
RflatCollectByte(Function<? super T, ? extends ByteIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableCharCollection>
RflatCollectChar(Function<? super T, ? extends CharIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableDoubleCollection>
RflatCollectDouble(Function<? super T, ? extends DoubleIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableFloatCollection>
RflatCollectFloat(Function<? super T, ? extends FloatIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableIntCollection>
RflatCollectInt(Function<? super T, ? extends IntIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableLongCollection>
RflatCollectLong(Function<? super T, ? extends LongIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableShortCollection>
RflatCollectShort(Function<? super T, ? extends ShortIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<V,R extends MutableMultimap<V, T>>
RSame asRichIterable.groupBy(Function), except that the results are gathered into the specifiedtargetmultimap.<V,R extends MutableMultimap<V, T>>
RgroupByEach(Function<? super T, ? extends Iterable<V>> function, R target) Same asRichIterable.groupByEach(Function), except that the results are gathered into the specifiedtargetmultimap.doubleinjectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function) Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.floatinjectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function) Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.intinjectInto(int injectedValue, IntObjectToIntFunction<? super T> function) Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.longinjectInto(long injectedValue, LongObjectToLongFunction<? super T> function) Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<IV> IVinjectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function) Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<IV,P> IV injectIntoWith(IV injectedValue, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter) <R extends Collection<T>>
RSame as the reject method with one parameter but uses the specified target collection for the results.<P,R extends Collection<T>>
RrejectWith(Predicate2<? super T, ? super P> predicate, P parameter, R target) Similar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.<R extends Collection<T>>
RSame as the select method with one parameter but uses the specified target collection for the results.<P,R extends Collection<T>>
RselectWith(Predicate2<? super T, ? super P> predicate, P parameter, R target) Similar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.doublesumOfDouble(DoubleFunction<? super T> function) Returns the final double result of evaluating function for each element of the iterable and adding the results together.doublesumOfFloat(FloatFunction<? super T> function) Returns the final double result of evaluating function for each element of the iterable and adding the results together.longsumOfInt(IntFunction<? super T> function) Returns the final long result of evaluating function for each element of the iterable and adding the results together.longsumOfLong(LongFunction<? super T> function) Returns the final long result of evaluating function for each element of the iterable and adding the results together.toBag()Converts the collection to the default MutableBag implementation.toList()Converts the collection to a MutableList implementation.toSet()Converts the collection to a MutableSet implementation.Converts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.toSortedBag(Comparator<? super T> comparator) Converts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.toSortedList(Comparator<? super T> comparator) Converts the collection to a MutableList implementation and sorts it using the specified comparator.Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.toSortedSet(Comparator<? super T> comparator) Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.Returns a string representation of this bag.Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, contains, containsAll, containsAllArguments, containsAllIterable, countByEach, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, forEach, forEachWith, forEachWithIndex, groupByUniqueKey, into, isEmpty, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, toArray, toArray, toBiMap, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, allSatisfyWithOccurrences, anySatisfyWithOccurrences, bottomOccurrences, collectWithOccurrences, collectWithOccurrences, detectWithOccurrences, distinctView, equals, forEachWithOccurrences, groupBy, groupByEach, hashCode, noneSatisfyWithOccurrences, occurrencesOf, partition, partitionWith, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectByOccurrences, selectDuplicates, selectInstancesOf, selectUnique, selectWith, sizeDistinct, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, tap, toImmutable, toMapOfItemToCount, topOccurrences, zipWithIndexMethods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArrayMethods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndexMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countBy, countByEach, countByEach, countByWith, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectWith, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupByAndCollect, groupByUniqueKey, groupByUniqueKey, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, size, sumByDouble, sumByFloat, sumByInt, sumByLong, toArray, toArray, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toMap, toMap, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zip, zip, zipWithIndex
-
Constructor Details
-
AbstractBag
public AbstractBag()
-
-
Method Details
-
select
Description copied from interface:RichIterableSame as the select method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> selected = people.select(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());- Specified by:
selectin interfaceRichIterable<T>- Overrides:
selectin classAbstractRichIterable<T>- Parameters:
predicate- aPredicateto use as the select criteriatarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
target, which contains appended elements as a result of the select criteria- See Also:
-
selectWith
public <P,R extends Collection<T>> R selectWith(Predicate2<? super T, ? super P> predicate, P parameter, R target) Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
MutableList<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge()>= age; } }, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
selectWithin interfaceRichIterable<T>- Overrides:
selectWithin classAbstractRichIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the select criteria- See Also:
-
reject
Description copied from interface:RichIterableSame as the reject method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());- Specified by:
rejectin interfaceRichIterable<T>- Overrides:
rejectin classAbstractRichIterable<T>- Parameters:
predicate- aPredicateto use as the reject criteriatarget- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
target, which contains appended elements as a result of the reject criteria
-
rejectWith
public <P,R extends Collection<T>> R rejectWith(Predicate2<? super T, ? super P> predicate, P parameter, R target) Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
MutableList<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> rejected = people.rejectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() < age; } }, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
rejectWithin interfaceRichIterable<T>- Overrides:
rejectWithin classAbstractRichIterable<T>- Parameters:
predicate- aPredicate2to use as the reject criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
targetCollection, which contains appended elements as a result of the reject criteria- See Also:
-
count
Description copied from interface:RichIterableReturn the total number of elements that answer true to the specified predicate.Example using a Java 8 lambda expression:
int count = people.count(person -> person.getAddress().getState().getName().equals("New York"));Example using an anonymous inner class:
int count = people.count(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });- Specified by:
countin interfaceRichIterable<T>- Overrides:
countin classAbstractRichIterable<T>
-
collect
Description copied from interface:RichIterableSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
MutableList<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<String> names = people.collect(new Function<Person, String>() { public String valueOf(Person person) { return person.getFirstName() + " " + person.getLastName(); } }, Lists.mutable.empty());- Specified by:
collectin interfaceRichIterable<T>- Overrides:
collectin classAbstractRichIterable<T>- Parameters:
function- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
target, which contains appended elements as a result of the collect transformation- See Also:
-
collectWith
public <P,V, R collectWithR extends Collection<V>> (Function2<? super T, ? super P, ? extends V> function, P parameter, R target) Description copied from interface:RichIterableSame as collectWith but with a targetCollection parameter to gather the results.Example using a Java 8 lambda expression:
MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());Example using an anonymous inner class:
Function2<Integer, Integer, Integer> addParameterFunction = new Function2<Integer, Integer, Integer>() { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), Sets.mutable.empty());- Specified by:
collectWithin interfaceRichIterable<T>- Overrides:
collectWithin classAbstractRichIterable<T>- Parameters:
function- aFunction2to use as the collect transformation functionparameter- a parameter to pass in for evaluation of the second argumentPinfunctiontarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
targetCollection, which contains appended elements as a result of the collect transformation
-
collectIf
public <V,R extends Collection<V>> R collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function, R target) Description copied from interface:RichIterableSame as the collectIf method with two parameters but uses the specified target collection for the results.- Specified by:
collectIfin interfaceRichIterable<T>- Overrides:
collectIfin classAbstractRichIterable<T>- Parameters:
predicate- aPredicateto use as the select criteriafunction- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat meet the collect criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the collect criteria and transformation- See Also:
-
flatCollect
public <V,R extends Collection<V>> R flatCollect(Function<? super T, ? extends Iterable<V>> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectin interfaceRichIterable<T>- Overrides:
flatCollectin classAbstractRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectBoolean
public <R extends MutableBooleanCollection> R collectBoolean(BooleanFunction<? super T> booleanFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
BooleanArrayList licenses = people.collectBoolean(person -> person.hasDrivingLicense(), new BooleanArrayList());Example using an anonymous inner class:
BooleanArrayList licenses = people.collectBoolean(new BooleanFunction<Person>() { public boolean booleanValueOf(Person person) { return person.hasDrivingLicense(); } }, new BooleanArrayList());- Specified by:
collectBooleanin interfaceRichIterable<T>- Parameters:
booleanFunction- aBooleanFunctionto use as the collect transformation functiontarget- the MutableBooleanCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectBoolean
public <R extends MutableBooleanCollection> R flatCollectBoolean(Function<? super T, ? extends BooleanIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectBooleanin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectByte
public <R extends MutableByteCollection> R collectByte(ByteFunction<? super T> byteFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
ByteArrayList bytes = people.collectByte(person -> person.getCode(), new ByteArrayList());Example using an anonymous inner class:
ByteArrayList bytes = people.collectByte(new ByteFunction<Person>() { public byte byteValueOf(Person person) { return person.getCode(); } }, new ByteArrayList());- Specified by:
collectBytein interfaceRichIterable<T>- Parameters:
byteFunction- aByteFunctionto use as the collect transformation functiontarget- the MutableByteCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectByte
public <R extends MutableByteCollection> R flatCollectByte(Function<? super T, ? extends ByteIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectBytein interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectChar
public <R extends MutableCharCollection> R collectChar(CharFunction<? super T> charFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
CharArrayList chars = people.collectChar(person -> person.getMiddleInitial(), new CharArrayList());Example using an anonymous inner class:
CharArrayList chars = people.collectChar(new CharFunction<Person>() { public char charValueOf(Person person) { return person.getMiddleInitial(); } }, new CharArrayList());- Specified by:
collectCharin interfaceRichIterable<T>- Parameters:
charFunction- aCharFunctionto use as the collect transformation functiontarget- the MutableCharCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectChar
public <R extends MutableCharCollection> R flatCollectChar(Function<? super T, ? extends CharIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectCharin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectDouble
public <R extends MutableDoubleCollection> R collectDouble(DoubleFunction<? super T> doubleFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
DoubleArrayList doubles = people.collectDouble(person -> person.getMilesFromNorthPole(), new DoubleArrayList());Example using an anonymous inner class:
DoubleArrayList doubles = people.collectDouble(new DoubleFunction<Person>() { public double doubleValueOf(Person person) { return person.getMilesFromNorthPole(); } }, new DoubleArrayList());- Specified by:
collectDoublein interfaceRichIterable<T>- Parameters:
doubleFunction- aDoubleFunctionto use as the collect transformation functiontarget- the MutableDoubleCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectDouble
public <R extends MutableDoubleCollection> R flatCollectDouble(Function<? super T, ? extends DoubleIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectDoublein interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectFloat
public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super T> floatFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
FloatArrayList floats = people.collectFloat(person -> person.getHeightInInches(), new FloatArrayList());Example using an anonymous inner class:
FloatArrayList floats = people.collectFloat(new FloatFunction<Person>() { public float floatValueOf(Person person) { return person.getHeightInInches(); } }, new FloatArrayList());- Specified by:
collectFloatin interfaceRichIterable<T>- Parameters:
floatFunction- aFloatFunctionto use as the collect transformation functiontarget- the MutableFloatCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectFloat
public <R extends MutableFloatCollection> R flatCollectFloat(Function<? super T, ? extends FloatIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectFloatin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectInt
Description copied from interface:RichIterableSame asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
IntArrayList ints = people.collectInt(person -> person.getAge(), new IntArrayList());Example using an anonymous inner class:
IntArrayList ints = people.collectInt(new IntFunction<Person>() { public int intValueOf(Person person) { return person.getAge(); } }, new IntArrayList());- Specified by:
collectIntin interfaceRichIterable<T>- Parameters:
intFunction- aIntFunctionto use as the collect transformation functiontarget- the MutableIntCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectInt
public <R extends MutableIntCollection> R flatCollectInt(Function<? super T, ? extends IntIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectIntin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectLong
public <R extends MutableLongCollection> R collectLong(LongFunction<? super T> longFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
LongArrayList longs = people.collectLong(person -> person.getGuid(), new LongArrayList());Example using an anonymous inner class:
LongArrayList longs = people.collectLong(new LongFunction<Person>() { public long longValueOf(Person person) { return person.getGuid(); } }, new LongArrayList());- Specified by:
collectLongin interfaceRichIterable<T>- Parameters:
longFunction- aLongFunctionto use as the collect transformation functiontarget- the MutableLongCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectLong
public <R extends MutableLongCollection> R flatCollectLong(Function<? super T, ? extends LongIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectLongin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
collectShort
public <R extends MutableShortCollection> R collectShort(ShortFunction<? super T> shortFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
ShortArrayList shorts = people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth, new ShortArrayList());Example using an anonymous inner class:
ShortArrayList shorts = people.collectShort(new ShortFunction<Person>() { public short shortValueOf(Person person) { return person.getNumberOfJunkMailItemsReceivedPerMonth; } }, new ShortArrayList());- Specified by:
collectShortin interfaceRichIterable<T>- Parameters:
shortFunction- aShortFunctionto use as the collect transformation functiontarget- the MutableShortCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectShort
public <R extends MutableShortCollection> R flatCollectShort(Function<? super T, ? extends ShortIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectShortin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
-
groupBy
public <V,R extends MutableMultimap<V, R groupByT>> (Function<? super T, ? extends V> function, R target) Description copied from interface:RichIterableSame asRichIterable.groupBy(Function), except that the results are gathered into the specifiedtargetmultimap.Example using a Java 8 method reference:
FastListMultimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName, new FastListMultimap<String, Person>());Example using an anonymous inner class:
FastListMultimap<String, Person> peopleByLastName = people.groupBy(new Function<Person, String>() { public String valueOf(Person person) { return person.getLastName(); } }, new FastListMultimap<String, Person>());- Specified by:
groupByin interfaceRichIterable<T>- Overrides:
groupByin classAbstractRichIterable<T>
-
groupByEach
public <V,R extends MutableMultimap<V, R groupByEachT>> (Function<? super T, ? extends Iterable<V>> function, R target) Description copied from interface:RichIterableSame asRichIterable.groupByEach(Function), except that the results are gathered into the specifiedtargetmultimap.- Specified by:
groupByEachin interfaceRichIterable<T>- Overrides:
groupByEachin classAbstractRichIterable<T>
-
sumOfInt
Description copied from interface:RichIterableReturns the final long result of evaluating function for each element of the iterable and adding the results together.- Specified by:
sumOfIntin interfaceRichIterable<T>- Overrides:
sumOfIntin classAbstractRichIterable<T>
-
sumOfFloat
Description copied from interface:RichIterableReturns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.- Specified by:
sumOfFloatin interfaceRichIterable<T>- Overrides:
sumOfFloatin classAbstractRichIterable<T>
-
sumOfLong
Description copied from interface:RichIterableReturns the final long result of evaluating function for each element of the iterable and adding the results together.- Specified by:
sumOfLongin interfaceRichIterable<T>- Overrides:
sumOfLongin classAbstractRichIterable<T>
-
sumOfDouble
Description copied from interface:RichIterableReturns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.- Specified by:
sumOfDoublein interfaceRichIterable<T>- Overrides:
sumOfDoublein classAbstractRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractRichIterable<T>
-
injectIntoWith
-
toStringOfItemToCount
Description copied from interface:BagReturns a string representation of this bag. The string representation consists of a list of element-count mappings.Assert.assertEquals("{1=1, 2=2, 3=3}", Bags.mutable.with(1, 2, 2, 3, 3, 3).toStringOfItemToCount());This string representation is similar toAbstractMap.toString(), notRichIterable.toString(), whereas thetoString()implementation for a Bag is consistent withRichIterable.toString().- Specified by:
toStringOfItemToCountin interfaceBag<T>- Returns:
- a string representation of this bag
-
toList
Description copied from interface:RichIterableConverts the collection to a MutableList implementation.- Specified by:
toListin interfaceRichIterable<T>- Overrides:
toListin classAbstractRichIterable<T>
-
toSortedList
Description copied from interface:RichIterableConverts the collection to a MutableList implementation and sorts it using the specified comparator.- Specified by:
toSortedListin interfaceRichIterable<T>
-
toSet
Description copied from interface:RichIterableConverts the collection to a MutableSet implementation.- Specified by:
toSetin interfaceRichIterable<T>- Overrides:
toSetin classAbstractRichIterable<T>
-
toSortedSet
Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.- Specified by:
toSortedSetin interfaceRichIterable<T>- Overrides:
toSortedSetin classAbstractRichIterable<T>
-
toSortedSet
Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.- Specified by:
toSortedSetin interfaceRichIterable<T>- Overrides:
toSortedSetin classAbstractRichIterable<T>
-
toBag
Description copied from interface:RichIterableConverts the collection to the default MutableBag implementation.- Specified by:
toBagin interfaceRichIterable<T>- Overrides:
toBagin classAbstractRichIterable<T>
-
toSortedBag
Description copied from interface:RichIterableConverts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.- Specified by:
toSortedBagin interfaceRichIterable<T>- Overrides:
toSortedBagin classAbstractRichIterable<T>
-
toSortedBag
Description copied from interface:RichIterableConverts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.- Specified by:
toSortedBagin interfaceRichIterable<T>- Overrides:
toSortedBagin classAbstractRichIterable<T>
-