Top Description Inners Constructors Methods
org.eclipse.collections.impl.bag.mutable

public Class UnmodifiableBag<T>

extends AbstractUnmodifiableMutableCollection<T>
implements MutableBag<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.eclipse.collections.api.bag.MutableBag, org.eclipse.collections.api.bag.MutableBagIterable, org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable, java.util.Collection, org.eclipse.collections.api.bag.Bag, org.eclipse.collections.api.bag.UnsortedBag
Imports
java.io.Externalizable, .IOException, .ObjectInput, .ObjectOutput, .Serializable, java.util.Collection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.ImmutableBag, .MutableBag, org.eclipse.collections.api.bag.primitive.MutableBooleanBag, .MutableByteBag, .MutableCharBag, .MutableDoubleBag, .MutableFloatBag, .MutableIntBag, .MutableLongBag, .MutableShortBag, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ObjectIntToObjectFunction, .ShortFunction, 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, org.eclipse.collections.api.factory.primitive.ObjectLongMaps, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.map.MutableMap, org.eclipse.collections.api.map.primitive.MutableObjectLongMap, org.eclipse.collections.api.multimap.bag.MutableBagMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.bag.PartitionMutableBag, org.eclipse.collections.api.set.MutableSet, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.api.tuple.primitive.ObjectIntPair, org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection

An unmodifiable view of a bag.
Since
1.0
See Also
MutableBag#asUnmodifiable()

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
pack-priv
UnmodifiableBag(MutableBag<? extends T> mutableBag)

Method Summary

Modifier and TypeMethod and Description
public int
addOccurrences(T item, int occurrences)

Implements org.eclipse.collections.api.bag.MutableBagIterable.addOccurrences.

Add number of occurrences for an item.

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
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 MutableBag<T>
public MutableBag<T>
public MutableList<ObjectIntPair<T>>
public <V> MutableBag<V>
collect(Function<? super T, ? extends V> function)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collect.

Implements org.eclipse.collections.api.bag.MutableBag.collect, org.eclipse.collections.api.collection.MutableCollection.collect.

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

public MutableBooleanBag
collectBoolean(BooleanFunction<? super T> booleanFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectBoolean.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectBoolean, org.eclipse.collections.api.collection.MutableCollection.collectBoolean.

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

public MutableByteBag
collectByte(ByteFunction<? super T> byteFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectByte.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectByte, org.eclipse.collections.api.collection.MutableCollection.collectByte.

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

public MutableCharBag
collectChar(CharFunction<? super T> charFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectChar.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectChar, org.eclipse.collections.api.collection.MutableCollection.collectChar.

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

public MutableDoubleBag
collectDouble(DoubleFunction<? super T> doubleFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectDouble.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectDouble, org.eclipse.collections.api.collection.MutableCollection.collectDouble.

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

public MutableFloatBag
collectFloat(FloatFunction<? super T> floatFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectFloat.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectFloat, org.eclipse.collections.api.collection.MutableCollection.collectFloat.

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

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

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectIf.

Implements org.eclipse.collections.api.bag.MutableBag.collectIf, org.eclipse.collections.api.collection.MutableCollection.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 MutableIntBag
collectInt(IntFunction<? super T> intFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectInt.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectInt, org.eclipse.collections.api.collection.MutableCollection.collectInt.

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

public MutableLongBag
collectLong(LongFunction<? super T> longFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectLong.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectLong, org.eclipse.collections.api.collection.MutableCollection.collectLong.

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

public MutableShortBag
collectShort(ShortFunction<? super T> shortFunction)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.collectShort.

Overrides default org.eclipse.collections.api.bag.MutableBag.collectShort, org.eclipse.collections.api.collection.MutableCollection.collectShort.

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

public <P, A> MutableBag<A>
public <V> MutableBag<V>
collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function)

Implements org.eclipse.collections.api.bag.MutableBag.collectWithOccurrences.

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

public <V, R extends Collection<V>> R
collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function, R target)

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

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

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 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 boolean
equals(Object obj)

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> MutableBag<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.

protected MutableBag<T>
public <V> MutableBagMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.groupBy.

Implements org.eclipse.collections.api.bag.MutableBag.groupBy, org.eclipse.collections.api.collection.MutableCollection.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> MutableBagMultimap<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 MutableBag<T>
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 static <E, B extends MutableBag<E>> UnmodifiableBag<E>
of(B bag)

This method will take a MutableBag and wrap it directly in a UnmodifiableBag.

public PartitionMutableBag<T>
public <P> PartitionMutableBag<T>
public MutableBag<T>
reject(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.reject.

Implements org.eclipse.collections.api.bag.MutableBag.reject, org.eclipse.collections.api.collection.MutableCollection.reject.

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

public <P> MutableBag<T>
public boolean
public MutableBag<T>
public MutableBag<T>
selectByOccurrences(IntPredicate predicate)

Implements org.eclipse.collections.api.bag.MutableBag.selectByOccurrences.

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

public <S> MutableBag<S>
public MutableSet<T>
selectUnique()

Overrides default org.eclipse.collections.api.bag.MutableBag.selectUnique.

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

public <P> MutableBag<T>
public boolean
public int
sizeDistinct()

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

The size of the Bag when counting only distinct elements.

public <V> MutableObjectLongMap<V>
public <V> MutableObjectLongMap<V>
public MutableBag<T>
public ImmutableBag<T>
public MutableMap<T, Integer>
toMapOfItemToCount()

Implements org.eclipse.collections.api.bag.MutableBag.toMapOfItemToCount.

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

public MutableList<ObjectIntPair<T>>
public String
toStringOfItemToCount()

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

Returns a string representation of this bag.

public MutableBag<T>
with(T element)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.with.

Overrides default org.eclipse.collections.api.bag.MutableBag.with.

Implements org.eclipse.collections.api.collection.MutableCollection.with.

This method allows mutable and fixed size collections the ability to add elements to their existing elements.

public MutableBag<T>
withAll(Iterable<? extends T> elements)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.withAll.

Overrides default org.eclipse.collections.api.bag.MutableBag.withAll.

Implements org.eclipse.collections.api.collection.MutableCollection.withAll.

This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.

public MutableBag<T>
public MutableBag<T>
without(T element)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.without.

Overrides default org.eclipse.collections.api.bag.MutableBag.without.

Implements org.eclipse.collections.api.collection.MutableCollection.without.

This method allows mutable and fixed size collections the ability to remove elements from their existing elements.

public MutableBag<T>
withoutAll(Iterable<? extends T> elements)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.withoutAll.

Overrides default org.eclipse.collections.api.bag.MutableBag.withoutAll.

Implements org.eclipse.collections.api.collection.MutableCollection.withoutAll.

This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.

public MutableBag<T>
protected Object
public <S> MutableBag<Pair<T, S>>
zip(Iterable<S> that)

Overrides org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection.zip.

Implements org.eclipse.collections.api.bag.MutableBag.zip, org.eclipse.collections.api.collection.MutableCollection.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 MutableSet<Pair<T, Integer>>
Inherited from org.eclipse.collections.impl.collection.mutable.AbstractUnmodifiableMutableCollection:
addaddAlladdAllIterableallSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringappendStringasLazychunkclearcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcontainscontainsAllcontainsAllArgumentscontainsAllIterablecontainsAnycontainsAnyIterablecontainsNonecontainsNoneIterablecountcountWithdetectdetectIfNonedetectOptionaldetectWithdetectWithIfNonedetectWithOptionaleachflatCollectflatCollectBooleanflatCollectByteflatCollectCharflatCollectDoubleflatCollectFloatflatCollectIntflatCollectLongflatCollectShortforEachWithforEachWithIndexgetFirstgetLastgetMutableCollectiongetOnlygroupBygroupByEachgroupByUniqueKeygroupByUniqueKeyinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoWithintoisEmptyiteratormakeStringmakeStringmakeStringmaxmaxmaxByminminminBynoneSatisfynoneSatisfyWithnotEmptyrejectrejectWithremoveremoveAllremoveAllIterableremoveIfremoveIfWithretainAllretainAllIterableselectselectAndRejectWithselectWithsizesumByDoublesumByFloatsumOfDoublesumOfFloatsumOfIntsumOfLongtoArraytoArraytoBagtoBiMaptoListtoMaptoMaptoSettoSortedBagtoSortedBagtoSortedListtoSortedListtoSortedMaptoSortedMaptoSortedMapBytoSortedSettoSortedSettoStringzipzipWithIndex