|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
mathCollection.AbstractMultiset
This class provides a skeletal implementation of the Multiset
interface to minimize the effort required to implement this interface.
Collection
,
AbstractCollection
,
HashMultiset
Constructor Summary | |
AbstractMultiset()
|
Method Summary | |
boolean |
equals(java.lang.Object o)
Compares the specified object with this multiset for equality. |
int |
hashCode()
Returns the hash code value for this multiset. |
boolean |
isDisjoint(java.util.Collection c)
Returns true if this multiset has no common element with the
specified set. |
boolean |
isSubset(java.util.Collection c)
Returns true if this multiset is a subset of the
specified collection. |
boolean |
isSuperset(java.util.Collection c)
Returns true if this multiset is a superset of the
specified collection. |
java.lang.String |
toString()
Returns a string representation of this multiset. |
Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface mathCollection.Multiset |
add, difference, getQuantity, intersection, remove, setQuantity, setSize, sum, symmetricDifference, toSet, union |
Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Constructor Detail |
public AbstractMultiset()
Method Detail |
public int hashCode()
s1.equals(s2)
implies that
s1.hashCode()==s2.hashCode()
for any two multisets
s1
and s2
, as required by the general contract
of Object.hashCode()
.
hashCode
in interface java.util.Collection
public java.lang.String toString()
"{}"
). Adjacent elements are separated by the characters
", "
(comma and space). Elements are converted to strings as
by Object.toString()
.
public boolean isSuperset(java.util.Collection c)
true
if this multiset is a superset of the
specified collection. That is, if all elements of the specified
collection are also present in this multiset at least the same number of
times.
This implementation first compares the sizes of this multiset and
the specified collection by invoking the size
method on
each. If this multiset is bigger than the specified collection then
each element of the specified collection is checked for presence in this
multiset (for multiple equal elements, the quantity in this
multiset has to be greater or equal). Otherwise, false
is
returned.
isSuperset
in interface Multiset
c
- collection to be checked for being a subset.
true
if this multiset is a superset of the
specifed collection, false
otherwise.isSubset(Collection)
public boolean isSubset(java.util.Collection c)
true
if this multiset is a subset of the
specified collection. That is, if all elements of this multiset are also
present in the specified collection at least the same number of times.
This implementation first compares the sizes of this multiset and
the specified collection by invoking the size
method on
each. If the specified collection is bigger than this multiset then
each element of this multiset is checked for presence in the specified
collection (for multiple equal elements, the quantity in the
specified collection has to be greater or equal). Otherwise,
false
is returned.
isSubset
in interface Multiset
c
- collection to be checked for being a superset.
true
if this multiset is a subset of the
specifed collection, false
otherwise.isSuperset(Collection)
public boolean isDisjoint(java.util.Collection c)
true
if this multiset has no common element with the
specified set.
This implementation checks whether the specified collection is an
instance of Multiset
or not. If so, it iterates over
the multiset that has fewer different elements. During iteration, only
different elements are taken into account. If the specified collection is
not an instance of Multiset
, it iterates over all elements
of the specified collection. If a common element is found, that is, if
an element is contained both in this multiset and in the specified
collection, false
is returned.
isDisjoint
in interface Multiset
c
- collection to be checked for common elements.
true
if this multiset has no common elements
with the specifed collection, false
otherwise.public boolean equals(java.lang.Object o)
true
if the specified object is also a collection, the two
sets have the same size, and every element of the specified set is
contained in this set the same number of times.
If the specified object is not this multiset itself but another
collection, this implementation first compares the sizes of this multiset
and the specified collection by invoking the size
method on
each. If the sizes match, the sets are compared on a per-element basis.
equals
in interface java.util.Collection
o
- object to be compared for equality with this multiset.
true
if the specified object is equal to this
multiset, false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |