Top Inners Fields Constructors Methods
org.eclipse.collections.impl.bag.immutable

public Class ImmutableArrayBag<T>

extends AbstractImmutableBag<T>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.Collection, .Comparator, .Iterator, .NoSuchElementException, .Optional, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.Bag, .ImmutableBag, .MutableBag, org.eclipse.collections.api.block.function.Function, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.predicate.primitive.IntPredicate, .ObjectIntPredicate, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.api.factory.Bags, .Sets, org.eclipse.collections.api.map.MutableMap, org.eclipse.collections.api.multimap.bag.ImmutableBagMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.set.ImmutableSet, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.bag.mutable.HashBag, org.eclipse.collections.impl.block.factory.Predicates2, org.eclipse.collections.impl.list.fixed.ArrayAdapter, org.eclipse.collections.impl.map.mutable.UnifiedMap, org.eclipse.collections.impl.multimap.bag.HashBagMultimap, org.eclipse.collections.impl.utility.ArrayIterate, .Iterate

Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final int[]
private final T[]
pack-priv static final int
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
ImmutableArrayBag(T[] keys, int[] counts)

Method Summary

Modifier and TypeMethod and Description
public boolean
allSatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.allSatisfy.

Implements org.eclipse.collections.api.RichIterable.allSatisfy.

Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.

public <P> boolean
allSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.allSatisfyWith.

Implements org.eclipse.collections.api.RichIterable.allSatisfyWith.

Returns true if the predicate evaluates to true for every element of the collection, or returns false.

public boolean
allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)

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

Returns true if the predicate evaluates to true for all elements of the Bag.

public boolean
anySatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.anySatisfy.

Implements org.eclipse.collections.api.RichIterable.anySatisfy.

Returns true if the predicate evaluates to true for any element of the iterable.

public <P> boolean
anySatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.anySatisfyWith.

Implements org.eclipse.collections.api.RichIterable.anySatisfyWith.

Returns true if the predicate evaluates to true for any element of the collection, or return false.

public boolean
anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)

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

Returns true if the predicate evaluates to true for any element of the Bag.

public <V> ImmutableBag<V>
collect(Function<? super T, ? extends V> function)

Implements org.eclipse.collections.api.bag.ImmutableBag.collect, org.eclipse.collections.api.RichIterable.collect, org.eclipse.collections.api.collection.ImmutableCollection.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection.

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

Implements org.eclipse.collections.api.bag.ImmutableBag.collectIf, org.eclipse.collections.api.RichIterable.collectIf, org.eclipse.collections.api.collection.ImmutableCollection.collectIf.

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.

public static <T> ImmutableArrayBag<T>
copyFrom(Bag<? extends T> bag)

public T
detect(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detect.

Implements org.eclipse.collections.api.RichIterable.detect.

Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.

public Optional<T>
detectOptional(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectOptional.

Implements org.eclipse.collections.api.RichIterable.detectOptional.

Returns the first element of the iterable for which the predicate evaluates to true as an Optional.

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

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectWith.

Implements org.eclipse.collections.api.RichIterable.detectWith.

Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.

public T
detectWithOccurrences(ObjectIntPredicate<? super T> predicate)

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

Returns an element of the Bag that satisfies the predicate or null if such an element does not exist

public <P> Optional<T>
detectWithOptional(Predicate2<? super T, ? super P> predicate, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectWithOptional.

Implements org.eclipse.collections.api.RichIterable.detectWithOptional.

Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.

public RichIterable<T>
distinctView()

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

Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation.

public void
each(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

public boolean
equals(Object other)

Overrides java.lang.Object.equals.

Implements org.eclipse.collections.api.bag.Bag.equals, java.util.Collection.equals.

Two bags b1 and b2 are equal if m1.toMapOfItemToCount().equals(m2.toMapOfItemToCount()).

public <V> ImmutableBag<V>
public void
forEachWithOccurrences(ObjectIntProcedure<? super T> objectIntProcedure)

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

For each distinct item, with the number of occurrences, execute the specified procedure.

public T
getFirst()

Implements org.eclipse.collections.api.RichIterable.getFirst.

Returns the first element of an iterable.

public T
getLast()

Implements org.eclipse.collections.api.RichIterable.getLast.

Returns the last element of an iterable.

public T
getOnly()

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

Returns the element if the iterable has exactly one element.

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

Implements org.eclipse.collections.api.bag.ImmutableBag.groupBy, org.eclipse.collections.api.bag.ImmutableBagIterable.groupBy, org.eclipse.collections.api.bag.Bag.groupBy, 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.

public <V> ImmutableBagMultimap<V, T>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements org.eclipse.collections.api.bag.Bag.hashCode, java.util.Collection.hashCode.

Returns the hash code for this Bag, defined as this.

public Iterator<T>
iterator()

Implements java.lang.Iterable.iterator, java.util.Collection.iterator.

Returns an iterator over elements of type T.

public T
max(Comparator<? super T> comparator)

Overrides org.eclipse.collections.impl.AbstractRichIterable.max.

Implements org.eclipse.collections.api.RichIterable.max.

Returns the maximum element out of this container based on the comparator.

public T
max()

Overrides org.eclipse.collections.impl.AbstractRichIterable.max.

Implements org.eclipse.collections.api.RichIterable.max.

Returns the maximum element out of this container based on the natural order.

public <V extends Comparable<? super V>> T
maxBy(Function<? super T, ? extends V> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.maxBy.

Implements org.eclipse.collections.api.RichIterable.maxBy.

Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.

public T
min(Comparator<? super T> comparator)

Overrides org.eclipse.collections.impl.AbstractRichIterable.min.

Implements org.eclipse.collections.api.RichIterable.min.

Returns the minimum element out of this container based on the comparator.

public T
min()

Overrides org.eclipse.collections.impl.AbstractRichIterable.min.

Implements org.eclipse.collections.api.RichIterable.min.

Returns the minimum element out of this container based on the natural order.

public <V extends Comparable<? super V>> T
minBy(Function<? super T, ? extends V> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.minBy.

Implements org.eclipse.collections.api.RichIterable.minBy.

Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.

private ImmutableBag<T>
newArrayBagWith(T element, int elementIndex, int distinctItemCount)

public static <T> ImmutableArrayBag<T>
newBagWith(T... elements)

public ImmutableBag<T>
newWith(T element)

Implements org.eclipse.collections.api.bag.ImmutableBag.newWith, org.eclipse.collections.api.collection.ImmutableCollection.newWith.

This method is similar to the with method in MutableCollection with the difference that a new copy of this collection with the element appended will be returned.

public ImmutableBag<T>
newWithAll(Iterable<? extends T> elements)

Implements org.eclipse.collections.api.bag.ImmutableBag.newWithAll, org.eclipse.collections.api.collection.ImmutableCollection.newWithAll.

This method is similar to the withAll method in MutableCollection with the difference that a new copy of this collection with the elements appended will be returned.

public ImmutableBag<T>
newWithout(T element)

Implements org.eclipse.collections.api.bag.ImmutableBag.newWithout, org.eclipse.collections.api.collection.ImmutableCollection.newWithout.

This method is similar to the without method in MutableCollection with the difference that a new copy of this collection with the element removed will be returned.

public boolean
noneSatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.noneSatisfy.

Implements org.eclipse.collections.api.RichIterable.noneSatisfy.

Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.

public <P> boolean
noneSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.noneSatisfyWith.

Implements org.eclipse.collections.api.RichIterable.noneSatisfyWith.

Returns true if the predicate evaluates to false for every element of the collection, or return false.

public boolean
noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)

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

Returns true if the Bag is empty or if the predicate evaluates to false for all elements of the Bag.

public int
occurrencesOf(Object item)

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

The occurrences of a distinct item in the bag.

public ImmutableBag<T>
public ImmutableBag<T>
public ImmutableBag<T>
public <S> ImmutableBag<S>
public int
size()

Implements org.eclipse.collections.api.RichIterable.size, java.util.Collection.size.

Returns the number of items in this iterable.

public int
sizeDistinct()

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

The size of the Bag when counting only distinct elements.

public MutableMap<T, Integer>
protected Object
public <S> ImmutableBag<Pair<T, S>>
zip(Iterable<S> that)

Implements org.eclipse.collections.api.bag.ImmutableBag.zip, org.eclipse.collections.api.RichIterable.zip, org.eclipse.collections.api.collection.ImmutableCollection.zip.

Deprecated in 6.0. Use OrderedIterable#zip(Iterable) instead.

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs.

public ImmutableSet<Pair<T, Integer>>
Inherited from org.eclipse.collections.impl.bag.immutable.AbstractImmutableBag:
bottomOccurrenceschunkcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIntcollectLongcollectShortcollectWithcollectWithOccurrencescountBycountByEachcountByWithgroupByUniqueKeynewWithoutAllpartitionpartitionWithrejectWithselectWithtaptoImmutabletopOccurrences