common
Class MultisetBackedSet
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet
common.MultisetBackedSet
- All Implemented Interfaces:
- java.lang.Iterable, java.util.Collection, java.util.Set
public class MultisetBackedSet
- extends java.util.AbstractSet
An unmodifiable Set that is backed by a Multiset. The elements in the
set are the distinct elements of the multiset.
Method Summary |
boolean |
contains(java.lang.Object o)
Returns true if this set contains the given element, that is, if
the underlying multiset contains at least one occurrence of
that element. |
java.util.Iterator |
iterator()
Returns an iterator over the elements of this set. |
int |
size()
Returns the size of this set, which is the number of distinct
elements in the underlying multiset. |
Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, containsAll, isEmpty, remove, 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.Set |
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray |
MultisetBackedSet
public MultisetBackedSet(Multiset s)
- Creates a new MultisetBackedSet backed by the given multiset.
size
public int size()
- Returns the size of this set, which is the number of distinct
elements in the underlying multiset.
- Specified by:
size
in interface java.util.Collection
- Specified by:
size
in interface java.util.Set
- Specified by:
size
in class java.util.AbstractCollection
contains
public boolean contains(java.lang.Object o)
- Returns true if this set contains the given element, that is, if
the underlying multiset contains at least one occurrence of
that element.
- Specified by:
contains
in interface java.util.Collection
- Specified by:
contains
in interface java.util.Set
- Overrides:
contains
in class java.util.AbstractCollection
iterator
public java.util.Iterator iterator()
- Returns an iterator over the elements of this set. This is like
calling entrySet().iterator() on the underlying multiset, except
that the objects returned by the iterator are the elements themselves,
not Multiset.Entry objects.
- Specified by:
iterator
in interface java.lang.Iterable
- Specified by:
iterator
in interface java.util.Collection
- Specified by:
iterator
in interface java.util.Set
- Specified by:
iterator
in class java.util.AbstractCollection