Top Methods
org.eclipse.collections.api.bag

public Interface ImmutableBagIterable<T>

extends Bag<T>, ImmutableCollection<T>
Known Direct Subinterfaces
org.eclipse.collections.api.bag.sorted.ImmutableSortedBag, org.eclipse.collections.api.bag.ImmutableBag
Imports
org.eclipse.collections.api.block.function.Function, org.eclipse.collections.api.block.function.primitive.ObjectIntToObjectFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.predicate.primitive.IntPredicate, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.collection.ImmutableCollection, org.eclipse.collections.api.map.MutableMapIterable, org.eclipse.collections.api.multimap.bag.ImmutableBagIterableMultimap, org.eclipse.collections.api.partition.bag.PartitionImmutableBagIterable, org.eclipse.collections.api.set.ImmutableSetIterable, org.eclipse.collections.api.tuple.Pair

Method Summary

Modifier and TypeMethod and Description
public <V> ImmutableCollection<V>
collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.Bag.collectWithOccurrences.

Iterates over the unique elements and their occurrences and collects the results of applying the specified function.

public <V> ImmutableBagIterableMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.Bag.groupBy, org.eclipse.collections.api.collection.ImmutableCollection.groupBy.

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.

public <V> ImmutableBagIterableMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.bag.Bag.groupByEach, org.eclipse.collections.api.collection.ImmutableCollection.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

public PartitionImmutableBagIterable<T>
partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.Bag.partition, org.eclipse.collections.api.collection.ImmutableCollection.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

public <P> PartitionImmutableBagIterable<T>
partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.partitionWith, org.eclipse.collections.api.collection.ImmutableCollection.partitionWith.

Filters a collection into a PartitionIterable based on the evaluation of the predicate.

public ImmutableBagIterable<T>
reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.Bag.reject, org.eclipse.collections.api.collection.ImmutableCollection.reject.

Returns all elements of the source collection that return false when evaluating of the predicate.

public <P> ImmutableBagIterable<T>
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.rejectWith, org.eclipse.collections.api.collection.ImmutableCollection.rejectWith.

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

public ImmutableBagIterable<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.Bag.select, org.eclipse.collections.api.collection.ImmutableCollection.select.

Returns all elements of the source collection that return true when evaluating the predicate.

public ImmutableBagIterable<T>
selectByOccurrences(IntPredicate predicate)

Redeclares org.eclipse.collections.api.bag.Bag.selectByOccurrences.

Returns all elements of the bag that have a number of occurrences that satisfy the predicate.

public default ImmutableBagIterable<T>
selectDuplicates()

Overrides default org.eclipse.collections.api.bag.Bag.selectDuplicates.

Returns all elements of the bag that have more than one occurrence.

public <S> ImmutableBagIterable<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.bag.Bag.selectInstancesOf, org.eclipse.collections.api.collection.ImmutableCollection.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public ImmutableSetIterable<T>
selectUnique()

Redeclares org.eclipse.collections.api.bag.Bag.selectUnique.

Returns a set containing all elements of the bag that have exactly one occurrence.

public <P> ImmutableBagIterable<T>
selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.selectWith, org.eclipse.collections.api.collection.ImmutableCollection.selectWith.

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

public ImmutableBagIterable<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.bag.Bag.tap, org.eclipse.collections.api.collection.ImmutableCollection.tap.

Executes the Procedure for each element in the iterable and returns this.

public MutableMapIterable<T, Integer>
toMapOfItemToCount()

Redeclares org.eclipse.collections.api.bag.Bag.toMapOfItemToCount.

Converts the Bag to a Map of the Item type to its count as an Integer.

public ImmutableSetIterable<Pair<T, Integer>>
Inherited from org.eclipse.collections.api.bag.Bag:
aggregateByallSatisfyWithOccurrencesanySatisfyWithOccurrencesbottomOccurrencescollectWithOccurrencesdetectWithOccurrencesdistinctViewequalsforEachWithOccurrenceshashCodenoneSatisfyWithOccurrencesoccurrencesOfreduceByreduceInPlacereduceInPlacesizeDistinctsummarizeDoublesummarizeFloatsummarizeIntsummarizeLongtoImmutabletopOccurrencestoStringOfItemToCount
Inherited from org.eclipse.collections.api.collection.ImmutableCollection:
aggregateByaggregateInPlaceBycastToCollectioncollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcountBycountByEachcountByWithflatCollectflatCollectWithgroupByUniqueKeynewWithnewWithAllnewWithoutnewWithoutAllparallelStreamreduceByspliteratorstreamsumByDoublesumByFloatsumByIntsumByLongzip

Method Detail

collectWithOccurrencesback to summary
public <V> ImmutableCollection<V> collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.Bag.collectWithOccurrences.

Doc from org.eclipse.collections.api.bag.Bag.collectWithOccurrences.

Iterates over the unique elements and their occurrences and collects the results of applying the specified function.

Annotations
@Override
groupByback to summary
public <V> ImmutableBagIterableMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.Bag.groupBy, org.eclipse.collections.api.collection.ImmutableCollection.groupBy.

Doc from org.eclipse.collections.api.RichIterable.groupBy.

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.

Example using a Java 8 method reference:

Multimap<String, Person> peopleByLastName =
    people.groupBy(Person::getLastName);
Annotations
@Override
groupByEachback to summary
public <V> ImmutableBagIterableMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.bag.Bag.groupByEach, org.eclipse.collections.api.collection.ImmutableCollection.groupByEach.

Doc from org.eclipse.collections.api.RichIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

Annotations
@Override
partitionback to summary
public PartitionImmutableBagIterable<T> partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.Bag.partition, org.eclipse.collections.api.collection.ImmutableCollection.partition.

Doc from org.eclipse.collections.api.RichIterable.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

Example using a Java 8 lambda expression:

PartitionIterable<Person> newYorkersAndNonNewYorkers =
    people.partition(person -> person.getAddress().getState().getName().equals("New York"));
Annotations
@Override
partitionWithback to summary
public <P> PartitionImmutableBagIterable<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.partitionWith, org.eclipse.collections.api.collection.ImmutableCollection.partitionWith.

Doc from org.eclipse.collections.api.RichIterable.partitionWith.

Filters a collection into a PartitionIterable based on the evaluation of the predicate.

Example using a Java 8 lambda expression:

PartitionIterable<Person> newYorkersAndNonNewYorkers =
    people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
Annotations
@Override
rejectback to summary
public ImmutableBagIterable<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.Bag.reject, org.eclipse.collections.api.collection.ImmutableCollection.reject.

Doc from org.eclipse.collections.api.RichIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.reject(person -> person.person.getLastName().equals("Smith"));
Annotations
@Override
rejectWithback to summary
public <P> ImmutableBagIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.rejectWith, org.eclipse.collections.api.collection.ImmutableCollection.rejectWith.

Doc from org.eclipse.collections.api.RichIterable.rejectWith.

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

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
Annotations
@Override
selectback to summary
public ImmutableBagIterable<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.Bag.select, org.eclipse.collections.api.collection.ImmutableCollection.select.

Doc from org.eclipse.collections.api.RichIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.select(person -> person.getAddress().getCity().equals("London"));
Annotations
@Override
selectByOccurrencesback to summary
public ImmutableBagIterable<T> selectByOccurrences(IntPredicate predicate)

Redeclares org.eclipse.collections.api.bag.Bag.selectByOccurrences.

Doc from org.eclipse.collections.api.bag.Bag.selectByOccurrences.

Returns all elements of the bag that have a number of occurrences that satisfy the predicate.

Annotations
@Override
selectDuplicatesback to summary
public default ImmutableBagIterable<T> selectDuplicates()

Overrides default org.eclipse.collections.api.bag.Bag.selectDuplicates.

Doc from org.eclipse.collections.api.bag.Bag.selectDuplicates.

Returns all elements of the bag that have more than one occurrence.

Annotations
@Override
Since
9.2
selectInstancesOfback to summary
public <S> ImmutableBagIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.bag.Bag.selectInstancesOf, org.eclipse.collections.api.collection.ImmutableCollection.selectInstancesOf.

Doc from org.eclipse.collections.api.RichIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

RichIterable<Integer> integers =
    List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
Annotations
@Override
selectUniqueback to summary
public ImmutableSetIterable<T> selectUnique()

Redeclares org.eclipse.collections.api.bag.Bag.selectUnique.

Doc from org.eclipse.collections.api.bag.Bag.selectUnique.

Returns a set containing all elements of the bag that have exactly one occurrence.

Annotations
@Override
Since
9.2
selectWithback to summary
public <P> ImmutableBagIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.selectWith, org.eclipse.collections.api.collection.ImmutableCollection.selectWith.

Doc from org.eclipse.collections.api.RichIterable.selectWith.

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

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
Annotations
@Override
tapback to summary
public ImmutableBagIterable<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.bag.Bag.tap, org.eclipse.collections.api.collection.ImmutableCollection.tap.

Doc from org.eclipse.collections.api.RichIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
toMapOfItemToCountback to summary
public MutableMapIterable<T, Integer> toMapOfItemToCount()

Redeclares org.eclipse.collections.api.bag.Bag.toMapOfItemToCount.

Doc from org.eclipse.collections.api.bag.Bag.toMapOfItemToCount.

Converts the Bag to a Map of the Item type to its count as an Integer.

Annotations
@Override
zipWithIndexback to summary
public ImmutableSetIterable<Pair<T, Integer>> zipWithIndex()

Redeclares org.eclipse.collections.api.bag.Bag.zipWithIndex, org.eclipse.collections.api.collection.ImmutableCollection.zipWithIndex.

Doc from org.eclipse.collections.api.RichIterable.zipWithIndex.

Zips this RichIterable with its indices.

Annotations
@Override