Top Constructors Methods
org.eclipse.collections.impl.bag

public abstract Class AbstractBag<T>

extends AbstractRichIterable<T>
implements Collection<T>, Bag<T>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.bag.Bag, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable, java.util.Collection
Known Direct Subclasses
org.eclipse.collections.impl.bag.immutable.AbstractImmutableBagIterable, org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable
Imports
java.util.Collection, .Collections, .Comparator, .StringJoiner, org.eclipse.collections.api.BooleanIterable, .ByteIterable, .CharIterable, .DoubleIterable, .FloatIterable, .IntIterable, .LongIterable, .ShortIterable, org.eclipse.collections.api.bag.Bag, .MutableBag, .MutableBagIterable, org.eclipse.collections.api.bag.primitive.MutableBooleanBag, .MutableByteBag, .MutableCharBag, .MutableDoubleBag, .MutableFloatBag, .MutableIntBag, .MutableLongBag, .MutableShortBag, org.eclipse.collections.api.bag.sorted.MutableSortedBag, org.eclipse.collections.api.block.function.Function, .Function2, .Function3, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .DoubleObjectToDoubleFunction, .FloatFunction, .FloatObjectToFloatFunction, .IntFunction, .IntObjectToIntFunction, .LongFunction, .LongObjectToLongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.collection.primitive.MutableBooleanCollection, .MutableByteCollection, .MutableCharCollection, .MutableDoubleCollection, .MutableFloatCollection, .MutableIntCollection, .MutableLongCollection, .MutableShortCollection, org.eclipse.collections.api.factory.Bags, .Lists, .Sets, .SortedBags, .SortedSets, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.multimap.MutableMultimap, org.eclipse.collections.api.set.MutableSet, org.eclipse.collections.api.set.sorted.MutableSortedSet, org.eclipse.collections.api.tuple.primitive.ObjectIntPair, org.eclipse.collections.impl.AbstractRichIterable, .Counter, org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples, org.eclipse.collections.impl.utility.Iterate

Since
7.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <V, R extends Collection<V>> R
collect(Function<? super T, ? extends V> function, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.collect.

Implements org.eclipse.collections.api.RichIterable.collect.

Same as collect(Function), except that the results are gathered into the specified target collection.

public <R extends MutableBooleanCollection> R
collectBoolean(BooleanFunction<? super T> booleanFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectBoolean.

Same as collectBoolean(BooleanFunction), except that the results are gathered into the specified target collection.

public <R extends MutableByteCollection> R
collectByte(ByteFunction<? super T> byteFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectByte.

Same as collectByte(ByteFunction), except that the results are gathered into the specified target collection.

public <R extends MutableCharCollection> R
collectChar(CharFunction<? super T> charFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectChar.

Same as collectChar(CharFunction), except that the results are gathered into the specified target collection.

public <R extends MutableDoubleCollection> R
collectDouble(DoubleFunction<? super T> doubleFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectDouble.

Same as collectDouble(DoubleFunction), except that the results are gathered into the specified target collection.

public <R extends MutableFloatCollection> R
collectFloat(FloatFunction<? super T> floatFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectFloat.

Same as collectFloat(FloatFunction), except that the results are gathered into the specified target collection.

public <V, R extends Collection<V>> R
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.collectIf.

Implements org.eclipse.collections.api.RichIterable.collectIf.

Same as the collectIf method with two parameters but uses the specified target collection for the results.

public <R extends MutableIntCollection> R
collectInt(IntFunction<? super T> intFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectInt.

Same as collectInt(IntFunction), except that the results are gathered into the specified target collection.

public <R extends MutableLongCollection> R
collectLong(LongFunction<? super T> longFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectLong.

Same as collectLong(LongFunction), except that the results are gathered into the specified target collection.

public <R extends MutableShortCollection> R
collectShort(ShortFunction<? super T> shortFunction, R target)

Overrides default org.eclipse.collections.api.RichIterable.collectShort.

Same as collectShort(ShortFunction), except that the results are gathered into the specified target collection.

public <P, V, R extends Collection<V>> R
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.collectWith.

Implements org.eclipse.collections.api.RichIterable.collectWith.

Same as collectWith but with a targetCollection parameter to gather the results.

public int
count(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.count.

Implements org.eclipse.collections.api.RichIterable.count.

Return the total number of elements that answer true to the specified predicate.

public <V, R extends Collection<V>> R
flatCollect(Function<? super T, ? extends Iterable<V>> function, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.flatCollect.

Implements org.eclipse.collections.api.RichIterable.flatCollect.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableBooleanCollection> R
flatCollectBoolean(Function<? super T, ? extends BooleanIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectBoolean.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableByteCollection> R
flatCollectByte(Function<? super T, ? extends ByteIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectByte.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableCharCollection> R
flatCollectChar(Function<? super T, ? extends CharIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectChar.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableDoubleCollection> R
flatCollectDouble(Function<? super T, ? extends DoubleIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectDouble.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableFloatCollection> R
flatCollectFloat(Function<? super T, ? extends FloatIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectFloat.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableIntCollection> R
flatCollectInt(Function<? super T, ? extends IntIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectInt.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableLongCollection> R
flatCollectLong(Function<? super T, ? extends LongIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectLong.

Same as flatCollect, only the results are collected into the target collection.

public <R extends MutableShortCollection> R
flatCollectShort(Function<? super T, ? extends ShortIterable> function, R target)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectShort.

Same as flatCollect, only the results are collected into the target collection.

public <V, R extends MutableMultimap<V, T>> R
groupBy(Function<? super T, ? extends V> function, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.groupBy.

Implements org.eclipse.collections.api.RichIterable.groupBy.

Same as groupBy(Function), except that the results are gathered into the specified target multimap.

public <V, R extends MutableMultimap<V, T>> R
groupByEach(Function<? super T, ? extends Iterable<V>> function, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.groupByEach.

Implements org.eclipse.collections.api.RichIterable.groupByEach.

Same as groupByEach(Function), except that the results are gathered into the specified target multimap.

public <IV> IV
injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public int
injectInto(int injectedValue, IntObjectToIntFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public long
injectInto(long injectedValue, LongObjectToLongFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public double
injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public float
injectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public <IV, P> IV
injectIntoWith(IV injectedValue, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter)

protected MutableList<ObjectIntPair<T>>
occurrencesSortingBy(int n, IntFunction<ObjectIntPair<T>> function, MutableList<ObjectIntPair<T>> returnWhenEmpty)

public <R extends Collection<T>> R
reject(Predicate<? super T> predicate, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.reject.

Implements org.eclipse.collections.api.RichIterable.reject.

Same as the reject method with one parameter but uses the specified target collection for the results.

public <P, R extends Collection<T>> R
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.rejectWith.

Implements org.eclipse.collections.api.RichIterable.rejectWith.

Similar to reject(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.

public <R extends Collection<T>> R
select(Predicate<? super T> predicate, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.select.

Implements org.eclipse.collections.api.RichIterable.select.

Same as the select method with one parameter but uses the specified target collection for the results.

public <P, R extends Collection<T>> R
selectWith(Predicate2<? super T, ? super P> predicate, P parameter, R target)

Overrides org.eclipse.collections.impl.AbstractRichIterable.selectWith.

Implements org.eclipse.collections.api.RichIterable.selectWith.

Similar to select(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.

public double
sumOfDouble(DoubleFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.sumOfDouble.

Implements org.eclipse.collections.api.RichIterable.sumOfDouble.

Returns the final double result of evaluating function for each element of the iterable and adding the results together.

public double
sumOfFloat(FloatFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.sumOfFloat.

Implements org.eclipse.collections.api.RichIterable.sumOfFloat.

Returns the final double result of evaluating function for each element of the iterable and adding the results together.

public long
sumOfInt(IntFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.sumOfInt.

Implements org.eclipse.collections.api.RichIterable.sumOfInt.

Returns the final long result of evaluating function for each element of the iterable and adding the results together.

public long
sumOfLong(LongFunction<? super T> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.sumOfLong.

Implements org.eclipse.collections.api.RichIterable.sumOfLong.

Returns the final long result of evaluating function for each element of the iterable and adding the results together.

public Object[]
toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection.

public <E> E[]
toArray(E[] array)

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

public MutableBag<T>
toBag()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toBag.

Implements org.eclipse.collections.api.RichIterable.toBag.

Converts the collection to the default MutableBag implementation.

public MutableList<T>
toList()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toList.

Implements org.eclipse.collections.api.RichIterable.toList.

Converts the collection to a MutableList implementation.

protected MutableList<ObjectIntPair<T>>
public MutableSet<T>
toSet()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toSet.

Implements org.eclipse.collections.api.RichIterable.toSet.

Converts the collection to a MutableSet implementation.

public MutableSortedBag<T>
toSortedBag()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toSortedBag.

Implements org.eclipse.collections.api.RichIterable.toSortedBag.

Converts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.

public MutableSortedBag<T>
toSortedBag(Comparator<? super T> comparator)

Overrides org.eclipse.collections.impl.AbstractRichIterable.toSortedBag.

Implements org.eclipse.collections.api.RichIterable.toSortedBag.

Converts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.

public MutableList<T>
toSortedList(Comparator<? super T> comparator)

Overrides default org.eclipse.collections.api.RichIterable.toSortedList.

Converts the collection to a MutableList implementation and sorts it using the specified comparator.

public MutableSortedSet<T>
toSortedSet()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toSortedSet.

Implements org.eclipse.collections.api.RichIterable.toSortedSet.

Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.

public MutableSortedSet<T>
toSortedSet(Comparator<? super T> comparator)

Overrides org.eclipse.collections.impl.AbstractRichIterable.toSortedSet.

Implements org.eclipse.collections.api.RichIterable.toSortedSet.

Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.

public String
toStringOfItemToCount()

Implements org.eclipse.collections.api.bag.Bag.toStringOfItemToCount.

Returns a string representation of this bag.

Inherited from org.eclipse.collections.impl.AbstractRichIterable:
allSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringasLazycontainscontainsAllcontainsAllArgumentscontainsAllIterablecountByEachcountWithdetectdetectOptionaldetectWithdetectWithIfNonedetectWithOptionalforEachforEachWithforEachWithIndexgroupByUniqueKeyintoisEmptymaxmaxmaxByminminminBynoneSatisfynoneSatisfyWithtoBiMaptoMaptoSortedBagBytoSortedListBytoSortedMaptoSortedMaptoSortedMapBytoSortedSetBytoStringzipzipWithIndex