common
Class AbstractMultiset

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

public abstract class AbstractMultiset
extends java.util.AbstractCollection
implements Multiset

Abstract implementation of the Multiset class.


Nested Class Summary
static class AbstractMultiset.Entry
          Abstract implementation of the Multiset.Entry interface.
 
Constructor Summary
AbstractMultiset()
           
 
Method Summary
 boolean contains(java.lang.Object o)
          Returns true if count(o) returns a number greater than zero.
abstract  int count(java.lang.Object o)
          Returns the number of occurrences of the given element in this multiset.
abstract  java.util.Set entrySet()
          Returns the set of entries in the multiset.
 boolean equals(java.lang.Object o)
          Two multisets are equal if they have the same elements with the same occurrence counts.
 int hashCode()
           
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, 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, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

AbstractMultiset

public AbstractMultiset()
Method Detail

count

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

Specified by:
count in interface Multiset

entrySet

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

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

contains

public boolean contains(java.lang.Object o)
Returns true if count(o) returns a number greater than zero.

Specified by:
contains in interface java.util.Collection
Overrides:
contains in class java.util.AbstractCollection

equals

public boolean equals(java.lang.Object o)
Two multisets are equal if they have the same elements with the same occurrence counts.

Specified by:
equals in interface java.util.Collection
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Overrides:
hashCode in class java.lang.Object