Suppose you have a MultiSet that contains {a, a, b, c}.
Calling getCount(Object) on a would return 2, while
calling uniqueSet() would return {a, b, c}.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | MultiSet.Entry<
the element type E>An unmodifiable entry for an element and its occurrence as contained in a MultiSet. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true always, as the size of the MultiSet is increased
in any casethe object to add object)Redeclares java. |
| public int | Returns: the number of occurrences of the object in the multiset before this operation; possibly zerothe object to add object, int the number of occurrences to add, may be zero,
in which case no change is made to the multiset occurrences)Adds a number of occurrences of the specified object to the MultiSet. |
| public boolean | Returns: true if the MultiSet contains all the collectionthe collection to check against coll)Redeclares java. true if the MultiSet contains at least one
occurrence for each element contained in the given collection.
|
| public Set | |
| public boolean | Returns: true if equalthe object to compare to obj)Redeclares java. |
| public int | |
| public int | Returns: the hash code of the MultiSetRedeclares java. |
| public Iterator | Returns: iterator over all elements in the MultiSetRedeclares java. Iterator over the entire set of members,
including copies due to cardinality.
|
| public boolean | Returns: true if this call changed the collectionthe object to remove object)Redeclares java. |
| public int | Returns: the number of occurrences of the object in the multiset before the operation; possibly zerothe object to remove object, int the number of occurrences to remove, may be zero,
in which case no change is made to the multiset occurrences)Removes a number of occurrences of the specified object from the MultiSet. |
| public boolean | Returns: true if this call changed the multisetthe collection of elements to remove coll)Redeclares java. |
| public boolean | Returns: true if this call changed the multisetthe collection of elements to retain coll)Redeclares java. |
| public int | Returns: the number of occurrences of the object before this operation, zero if the object was not contained in the multisetthe object to update object, int the number of occurrences of the object count)Sets the number of occurrences of the specified object in the MultiSet to the given count. |
| public int | Returns: the total size of the multisetRedeclares java. |
| public Set |
| add | back to summary |
|---|---|
| public boolean add(E object) Redeclares java. Adds one copy of the specified object to the MultiSet.
If the object is already in the
| |
| add | back to summary |
|---|---|
| public int add(E object, int occurrences) Adds a number of occurrences of the specified object to the MultiSet.
If the object is already in the
| |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(Collection<?> coll) Redeclares java. Returns
| |
| entrySet | back to summary |
|---|---|
| public Set Returns a The returned set is backed by this multiset, so any change to either is immediately reflected in the other. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Redeclares java. Compares this MultiSet to another object. This MultiSet equals another object if it is also a MultiSet that contains the same number of occurrences of the same elements. | |
| getCount | back to summary |
|---|---|
| public int getCount(Object object) Returns the number of occurrences of the given object currently in the MultiSet. If the object does not exist in the multiset, return 0.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Redeclares java. Gets a hash code for the MultiSet compatible with the definition of equals.
The hash code is defined as the sum total of a hash code for each element.
The per element hash code is defined as
| |
| iterator | back to summary |
|---|---|
| public Iterator Redeclares java. Returns an | |
| remove | back to summary |
|---|---|
| public boolean remove(Object object) Redeclares java. Removes one occurrence of the given object from the MultiSet.
If the number of occurrences after this operations is reduced
to zero, the object will be removed from the | |
| remove | back to summary |
|---|---|
| public int remove(Object object, int occurrences) Removes a number of occurrences of the specified object from the MultiSet. If the number of occurrences to remove is greater than the actual number of occurrences in the multiset, the object will be removed from the multiset.
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> coll) Redeclares java. Remove all occurrences of all elements from this MultiSet represented in the given collection.
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> coll) Redeclares java. Remove any elements of this MultiSet that are not contained in the given collection.
| |
| setCount | back to summary |
|---|---|
| public int setCount(E object, int count) Sets the number of occurrences of the specified object in the MultiSet to the given count.
If the provided count is zero, the object will be removed from the
| |
| size | back to summary |
|---|---|
| public int size() Redeclares java. Returns the total number of items in the MultiSet.
| |
| uniqueSet | back to summary |
|---|---|
| public Set Returns a
Uniqueness constraints are the same as those in The returned set is backed by this multiset, so any change to either is immediately reflected in the other. Only removal operations are supported, in which case all occurrences of the element are removed from the backing multiset.
| |
The MultiSet#entrySet() method returns a view of the multiset whose elements
implements this interface.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public int | Returns: the number of occurrences of the elementReturns the number of occurrences for the element of this entry. |
| public E | Returns: the element corresponding to this entryReturns the element corresponding to this entry. |
| public int | Returns: the hash code value for this multiset entryReturns the hash code value for this multiset entry. |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Compares the specified object with this entry for equality. Returns true if the given object is also a multiset entry and the two entries represent the same element with the same number of occurrences.
More formally, two entries
(e1.getElement()==null ? e2.getElement()==null
: e1.getElement().equals(e2.getElement())) &&
(e1.getCount()==e2.getCount())
| |
| getCount | back to summary |
|---|---|
| public int getCount() Returns the number of occurrences for the element of this entry.
| |
| getElement | back to summary |
|---|---|
| public E getElement() Returns the element corresponding to this entry.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Returns the hash code value for this multiset entry.
The hash code of a multiset entry
(e==null ? 0 : e.hashCode()) ^ noOccurances)
| |