common
Class SetBackedMultiset

java.lang.Object
  extended by java.util.AbstractCollection
      extended by common.AbstractMultiset
          extended by common.SetBackedMultiset
All Implemented Interfaces:
Multiset, java.lang.Iterable, java.util.Collection

public class SetBackedMultiset
extends AbstractMultiset

An unmodifiable Multiset implementation that just wraps around a Set object.


Constructor Summary
SetBackedMultiset(java.util.Set s)
          Creates a new SetBackedMultiset that will be backed by the given set.
 
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.
 java.util.Iterator iterator()
          Returns an iterator over this multiset.
 int size()
          Returns the number of elements in this multiset.
 
Methods inherited from class common.AbstractMultiset
contains, equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
add, addAll, clear, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SetBackedMultiset

public SetBackedMultiset(java.util.Set s)
Creates a new SetBackedMultiset that will be backed by the given set. If the contents of the given set change, the contents of this SetBackedMultiset will change too.

Method Detail

size

public int size()
Returns the number of elements in this multiset.

Specified by:
size in interface java.util.Collection
Specified by:
size in class java.util.AbstractCollection

count

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

Specified by:
count in interface Multiset
Specified by:
count in class AbstractMultiset

iterator

public java.util.Iterator iterator()
Returns an iterator over this multiset. If the multiset contains n copies of an element, the iterator will return that element n times.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in class java.util.AbstractCollection

entrySet

public 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.

Specified by:
entrySet in interface Multiset
Specified by:
entrySet in class AbstractMultiset
Returns:
a Set of Multiset.Entry objects