common
Interface Multiset

All Superinterfaces:
java.util.Collection, java.lang.Iterable
All Known Implementing Classes:
AbstractMultiset, HashMultiset, SetBackedMultiset

public interface Multiset
extends java.util.Collection

A multiset is like a set, except that it can include multiple copies of an element. It differs from a list in that the element occurrences are not in any order. Formally, a multiset consists of a set S and a function m(x) that maps each element x of S to the number of times it occurs in the multiset.

The Multiset interface extends the Collection interface, adding methods for getting the number of distinct elements and the number of times a given element occurs in the multiset. Its size() method returns the sum of the occurrence counts of all the elements. The iterator returned by the iterator() method on a multiset may return multiple copies of the same element. To get an iterator over the distinct elements, use distinctIterator().


Nested Class Summary
static interface Multiset.Entry
          Interface for objects that represent entries in a multiset.
 
Method Summary
 int count(java.lang.Object o)
          Returns the number of occurrences of the given element in this multiset.
 java.util.Set entrySet()
          Returns the set of entries in the multiset.
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

count

int count(java.lang.Object o)
Returns the number of occurrences of the given element in this multiset.


entrySet

java.util.Set entrySet()
Returns the set of entries in the multiset. An entry is a pair (e, n) where e is an element of the multiset and n is the number of times e occurs in the multiset. The returned set contains exactly one entry for each distinct element e. Thus, entrySet.size() returns the number of distinct elements in the multiset.

The returned set supports element removal: removing an entry corresponds to deleting all occurrences of the corresponding element from the multiset. However, the returned set does not support the add or addAll methods.

Returns:
a Set of Multiset.Entry objects