|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Multiset<E>
An unordered collection similar to a Set, but which may
contain duplicate elements.
| Nested Class Summary | |
|---|---|
static interface |
Multiset.Entry<E>
A multiset entry (element-count pair). |
| Method Summary | |
|---|---|
boolean |
add(E element,
int occurrences)
Adds a number of occurrences of the specified element to this multiset. |
int |
count(Object element)
Returns the number of occurrences of the specified element in this multiset. |
Set<E> |
elementSet()
Returns a view of the elements of this multiset as a set. |
Set<Multiset.Entry<E>> |
entrySet()
Returns the data of this multiset as a set of Entry instances. |
boolean |
equals(Object object)
Compares the specified object with this multiset for equality. |
int |
hashCode()
Returns the hash code for this multiset. |
int |
remove(Object element,
int occurrences)
Removes a number of occurrences of the specified element from this multiset. |
int |
removeAllOccurrences(Object element)
Removes all occurrences of the specified element from this multiset. |
| Methods inherited from interface java.util.Collection |
|---|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Method Detail |
|---|
int count(@Nullable
Object element)
element - the element to look for
Iterables.frequency(java.lang.Iterable>, java.lang.Object)
boolean add(@Nullable
E element,
int occurrences)
element - the element to addoccurrences - the number of occurrences to add
true if the collection changed as a result (this should
always be the case unless occurrences is zero)
IllegalArgumentException - if occurrences is negative
int remove(@Nullable
Object element,
int occurrences)
element - the element whose occurrences should be removedoccurrences - the number of occurrences of this element to remove
IllegalArgumentException - if occurrences is negative
int removeAllOccurrences(@Nullable
Object element)
remove(java.lang.Object, int), which removes only one
occurrence at a time.
element - the element whose occurrences should all be removed
Set<E> elementSet()
elementSet().size() to find
the number of distinct elements in this multiset.
Set<Multiset.Entry<E>> entrySet()
Entry instances. This
set contains precisely one Entry instance for each distinct element
of the multiset. The iteration order of this set is
implementation-dependent.
boolean equals(@Nullable
Object object)
true if the given object is also a multiset and contains equal
elements with equal counts.
equals in interface Collection<E>equals in class Objectint hashCode()
(element == null ? 0 : element.hashCode()) ^ count(element)over all elements in the multiset.
hashCode in interface Collection<E>hashCode in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||