iterator() as this method requires an external lock
to be taken to provide thread-safe iteration. All of these methods are available however, if you use the
withReadLockAndDelegate() or withWriteLockAndDelegate() methods. Both of these methods take a parameter of type
Procedure<MutableBag>, and a wrapped version of the underlying HashBag is returned. This wrapper guarantees that
no external pointer can ever reference the underlying HashBag outside a locked procedure. In the case of the
read lock method, an Unmodifiable version of the collection is offered, which will throw UnsupportedOperationExceptions
on any write methods like add or remove.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private HashBag | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | addOccurrences(T item, int occurrences)
Implements org. Add number of |
| public boolean | allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. Returns true if the predicate evaluates to true for all elements of the Bag. |
| public boolean | anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. Returns true if the predicate evaluates to true for any element of the Bag. |
| pack-priv MultiReaderHashBag. | |
| public MutableBag | asSynchronized()
Implements org. Returns a synchronized wrapper backed by this collection. |
| public MutableBag | asUnmodifiable()
Implements org. Returns an unmodifiable view of this collection. |
| pack-priv MultiReaderHashBag. | |
| public MutableList | bottomOccurrences(int count)
Implements org. Returns the |
| public RichIterable | chunk(int size)
Implements org. Partitions elements in fixed size chunks. |
| public <V> MutableBag | collect(Function<? super T, ? extends V> function)
Implements org. 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 default org. Returns a new primitive |
| public MutableByteBag | collectByte(ByteFunction<? super T> byteFunction)
Overrides default org. Returns a new primitive |
| public MutableCharBag | collectChar(CharFunction<? super T> charFunction)
Overrides default org. Returns a new primitive |
| public MutableDoubleBag | collectDouble(DoubleFunction<? super T> doubleFunction)
Overrides default org. Returns a new primitive |
| public MutableFloatBag | collectFloat(FloatFunction<? super T> floatFunction)
Overrides default org. Returns a new primitive |
| public <V> MutableBag | collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)
Implements org. 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 default org. Returns a new primitive |
| public MutableLongBag | collectLong(LongFunction<? super T> longFunction)
Overrides default org. Returns a new primitive |
| public MutableShortBag | collectShort(ShortFunction<? super T> shortFunction)
Overrides default org. Returns a new primitive |
| public <P, V> MutableBag | collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)
Implements org. Same as |
| public <V> MutableBag | collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function)
Implements org. Iterates over the unique elements and their occurrences and collects the results of applying the specified function. |
| public <V, R extends Collection | collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function, R target)
Overrides default org. 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. Returns an element of the Bag that satisfies the predicate or null if such an element does not exist |
| public RichIterable | distinctView()
Overrides default org. Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation. |
| public boolean | equals(Object o)
Overrides java. Implements org. Two bags |
| public <V> MutableBag | flatCollect(Function<? super T, ? extends Iterable<V>> function)
Implements org.
|
| public void | forEachWithOccurrences(ObjectIntProcedure<? super T> procedure)
Implements org. For each distinct item, with the number of occurrences, execute the specified procedure. |
| protected MutableBag | |
| public <V> MutableBagMultimap | groupBy(Function<? super T, ? extends V> function)
Implements org. 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 | groupByEach(Function<? super T, ? extends Iterable<V>> function)
Implements org. Similar to |
| public <V> MutableMap | groupByUniqueKey(Function<? super T, ? extends V> function)
Overrides default org. Implements org. For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key. |
| public int | hashCode()
Overrides java. Implements org. Returns the hash code for this Bag, defined as this. |
| public static <T> MultiReaderHashBag | |
| public static <T> MultiReaderHashBag | |
| public static <T> MultiReaderHashBag | |
| public static <T> MultiReaderHashBag | |
| public MultiReaderBag | newEmpty()
Implements org. Creates a new empty mutable version of the same collection type. |
| public boolean | noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. 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. The occurrences of a distinct item in the bag. |
| public PartitionMutableBag | partition(Predicate<? super T> predicate)
Implements org. Filters a collection into a PartitionedIterable based on the evaluation of the predicate. |
| public <P> PartitionMutableBag | partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)
Implements org. Filters a collection into a PartitionIterable based on the evaluation of the predicate. |
| public void | readExternal(ObjectInput in)
Implements java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. |
| public MutableBag | reject(Predicate<? super T> predicate)
Implements org. Returns all elements of the source collection that return false when evaluating of the predicate. |
| public <P> MutableBag | rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)
Implements org. Similar to |
| public boolean | removeOccurrences(Object item, int occurrences)
Implements org.
|
| public MutableBag | select(Predicate<? super T> predicate)
Implements org. Returns all elements of the source collection that return true when evaluating the predicate. |
| public MutableBag | selectByOccurrences(IntPredicate predicate)
Implements org. Returns all elements of the bag that have a number of occurrences that satisfy the predicate. |
| public <S> MutableBag | selectInstancesOf(Class<S> clazz)
Implements org. Returns all elements of the source collection that are instances of the Class |
| public MutableSet | selectUnique()
Overrides default org. Returns a set containing all elements of the bag that have exactly one occurrence. |
| public <P> MutableBag | selectWith(Predicate2<? super T, ? super P> predicate, P parameter)
Implements org. Similar to |
| public boolean | setOccurrences(T item, int occurrences)
Implements org.
|
| public int | sizeDistinct()
Implements org. The size of the Bag when counting only distinct elements. |
| public <V> MutableObjectLongMap | sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function)
Overrides org. Implements org. Groups and sums the values using the two specified functions. |
| public <V> MutableObjectLongMap | sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function)
Overrides org. Implements org. Groups and sums the values using the two specified functions. |
| public MultiReaderBag | tap(Procedure<? super T> procedure)
Overrides default org. Implements org. Executes the Procedure for each element in the iterable and returns |
| public ImmutableBag | toImmutable()
Implements org. Converts this |
| public MutableMap | toMapOfItemToCount()
Implements org. Converts the Bag to a Map of the Item type to its count as an Integer. |
| public MutableList | topOccurrences(int count)
Implements org. Returns the |
| public String | toStringOfItemToCount()
Implements org. Returns a string representation of this bag. |
| public void | trimToSize()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels. |
| public void | withReadLockAndDelegate(Procedure<? super MutableBag<T>> procedure)
Implements org.
|
| public void | withWriteLockAndDelegate(Procedure<? super MutableBag<T>> procedure)
Implements org.
|
| public void | writeExternal(ObjectOutput out)
Implements java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays. |
| public <S> MutableBag | zip(Iterable<S> that)
Implements org.
Deprecated
in 6.0. Use
OrderedIterable#zip(Iterable) instead.
Returns a |
| public MutableSet | zipWithIndex()
Implements org.
Deprecated
in 6.0. Use
OrderedIterable#zipWithIndex() instead.
Zips this |