Multiset operations (exceptions where noted). Null elements are not supported.
See the Guava User Guide article on Multiset.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final transient ConcurrentMap | countMap
The number of occurrences of each element. |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the previous count of the element before the operation; possibly zerothe element to add element, int the number of occurrences to add occurrences)Overrides com. Implements com. |
| public void | clear()
Implements abstract com. Implements java. |
| public int | Returns: the nonnegative number of occurrences of the elementthe element to look for element)Implements com. element in this multiset.
|
| public static <E> ConcurrentHashMultiset | create()
Creates a new, empty |
| public static <E> ConcurrentHashMultiset | |
| public static <E> ConcurrentHashMultiset | create(ConcurrentMap<E, AtomicInteger>
backing map for storing the elements in the multiset and their counts. It must
be empty. countMap)Creates a new, empty |
| pack-priv Set | createElementSet()
Overrides com. elementSet().
|
| public Set | createEntrySet()
Overrides com.
Deprecated
Internal method, use
entrySet().
|
| pack-priv int | |
| pack-priv Iterator | |
| pack-priv Iterator | |
| public boolean | isEmpty()
Overrides com. Implements java. true if this collection contains no elements.
|
| public Iterator | iterator()
Implements abstract java. Implements com. |
| private void | |
| public int | Returns: the count of the element before the operation; possibly zerothe element whose occurrences should be removed element, int the number of occurrences of the element to remove occurrences)Overrides com. Implements com. |
| public boolean | Returns: true if the removal was possible (including if occurrences is zero)the element to remove element, int the number of occurrences of occurrences)element to removeRemoves exactly the specified number of occurrences of |
| public int | Returns: the count ofelement in the multiset before this callthe element to add or remove occurrences of; may be null only if explicitly
allowed by the implementation element, int the desired count of the element in this multiset count)Overrides com. Implements com. element such that the count of the element
becomes count.
|
| public boolean | Returns: true if the change was successful. This usually indicates that the multiset has
been modified, but not always: in the case that expectedOldCount == newCount, the
method will return true if the condition was met.the element to conditionally set the count of; may be null only if explicitly
allowed by the implementation element, int the expected present count of the element in this multiset expectedOldCount, int the desired count of the element in this multiset newCount)Overrides com. Implements com. element to newCount, but only if the count is
currently expectedOldCount.
|
| public int | size()
Implements abstract java. Implements com. |
| private List | |
| public Object[] | toArray()
Overrides java. Implements java. |
| public <T extends @Nullable Object> T[] | toArray(T[]
the array into which the elements of this collection are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose. array)Overrides java. Implements java. |
| private void |
| countMap | back to summary |
|---|---|
| private final transient ConcurrentMap<E, AtomicInteger> countMap The number of occurrences of each element. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ConcurrentHashMultiset | back to summary |
|---|---|
pack-priv ConcurrentHashMultiset(ConcurrentMap<E, AtomicInteger> countMap)
| |
| add | back to summary |
|---|---|
| public int add(E element, int occurrences) Overrides com. Implements com. Adds a number of occurrences of the specified element to this multiset.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements abstract com. Implements java. Doc from java. Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.
| |
| count | back to summary |
|---|---|
| public int count(Object element) Implements com. Returns the number of occurrences of | |
| create | back to summary |
|---|---|
| public static <E> ConcurrentHashMultiset Creates a new, empty | |
| create | back to summary |
|---|---|
| public static <E> ConcurrentHashMultiset Creates a new This implementation is highly efficient when
| |
| create | back to summary |
|---|---|
| public static <E> ConcurrentHashMultiset Creates a new, empty This instance will assume ownership of The returned multiset is serializable if the input map is.
| |
| createElementSet | back to summary |
|---|---|
| pack-priv Set Overrides com. Doc from com. Creates a new instance of this multiset's element set, which will be returned by
| |
| createEntrySet | back to summary |
|---|---|
| public Set Overrides com. Deprecated Internal method, use
| |
| distinctElements | back to summary |
|---|---|
| pack-priv int distinctElements() Implements abstract com.
| |
| elementIterator | back to summary |
|---|---|
| pack-priv Iterator Implements abstract com.
| |
| entryIterator | back to summary |
|---|---|
| pack-priv Iterator Implements abstract com.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides com. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements com. Doc from com. Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee). Elements that occur multiple times in the multiset will appear multiple times in this iterator, though not necessarily sequentially.
| |
| readObject | back to summary |
|---|---|
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
| |
| remove | back to summary |
|---|---|
| public int remove(Object element, int occurrences) Overrides com. Implements com. Removes a number of occurrences of the specified element from this multiset. If the multiset contains fewer than this number of occurrences to begin with, all occurrences will be removed.
| |
| removeExactly | back to summary |
|---|---|
| public boolean removeExactly(Object element, int occurrences) Removes exactly the specified number of occurrences of This method, in contrast to
| |
| setCount | back to summary |
|---|---|
| public int setCount(E element, int count) Overrides com. Implements com. Adds or removes occurrences of
| |
| setCount | back to summary |
|---|---|
| public boolean setCount(E element, int expectedOldCount, int newCount) Overrides com. Implements com. Sets the number of occurrences of
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements com. Doc from com. Returns the total number of all occurrences of all elements in this multiset. Note this method does not return the number of distinct elements in the
multiset, which is given by If the data in the multiset is modified by any other threads during this method, it is undefined which (if any) of these modifications will be reflected in the result.
| |
| snapshot | back to summary |
|---|---|
| private List | |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this collection.
If this collection makes any guarantees as to what order its elements
are returned by its iterator, this method must return the elements in
the same order. The returned array's runtime component type is The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
| |
| toArray | back to summary |
|---|---|
| public <T extends @Nullable Object> T[] toArray(T[] array) Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection. If this collection fits in the specified array with room to spare
(i.e., the array has more elements than this collection), the element
in the array immediately following the end of the collection is set to
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
| |
| writeObject | back to summary |
|---|---|
private void writeObject(ObjectOutputStream stream) throws IOException
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv ConcurrentHashMultiset | |
| private List | |
| public Object[] | toArray()
Overrides java. Implements java. |
| public <T extends @Nullable Object> T[] | toArray(T[]
the array into which the elements of this set are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose. array)Overrides java. Implements java. |
| EntrySet | back to summary |
|---|---|
| private EntrySet() | |
| multiset | back to summary |
|---|---|
| pack-priv ConcurrentHashMultiset Overrides com.
| |
| snapshot | back to summary |
|---|---|
| private List | |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs. | |
| toArray | back to summary |
|---|---|
| public <T extends @Nullable Object> T[] toArray(T[] array) Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set. If this set fits in the specified array with room to spare
(i.e., the array has more elements than this set), the element in
the array immediately following the end of the set is set to
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. Like the Suppose
String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to
toArray().
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Serialization. |
| Access | Constructor and Description |
|---|---|
| private |
| COUNT_MAP_FIELD_SETTER | back to summary |
|---|---|
| pack-priv static final Serialization. | |
| FieldSettersHolder | back to summary |
|---|---|
| private FieldSettersHolder() | |