|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An extension of java.util.Collection for representing mathematical multisets.
Collection
,
AbstractMultiset
,
HashMultiset
Method Summary | |
boolean |
add(java.lang.Object o,
int quantity)
Adds the specified element quantity of times to this
multiset. |
Multiset |
difference(java.util.Collection c)
Returns the asymmetric difference between this multiset and the specified collection. |
int |
getQuantity(java.lang.Object o)
Returns the number of times the specified element is present in this multiset. |
Multiset |
intersection(java.util.Collection c)
Returns the intersection with the specified collection. |
boolean |
isDisjoint(java.util.Collection c)
Returns true if the specified collection has no common
elements with this multiset. |
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. |
boolean |
remove(java.lang.Object o,
int quantity)
Removes the specified element quantity of times from this
multiset if possible. |
boolean |
setQuantity(java.lang.Object o,
int quantity)
Adjusts the number of times the specified element is present in this multiset to be the specified value. |
int |
setSize()
Returns the size of a 'flattened' version of this multiset in which every element of this multiset is present exactly once. |
Multiset |
sum(java.util.Collection c)
Returns the sum with the specified collection. |
Multiset |
symmetricDifference(java.util.Collection c)
Returns the symmetric difference between this multiset and the specified collection. |
java.util.Set |
toSet()
Returns a 'flattened' version of this multiset in which every element of this multiset is present exactly once. |
Multiset |
union(java.util.Collection c)
Returns the union with the specified collection. |
Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Method Detail |
public boolean add(java.lang.Object o, int quantity)
quantity
of times to this
multiset. If quantity
is negative or 0, false
is returned.
o
- element to be added to this set.quantity
- quantity of elements to add.
true
if quantity
is
greater than 0, false
otherwisepublic boolean remove(java.lang.Object o, int quantity)
quantity
of times from this
multiset if possible. If quantity
is negative or 0,
false
is returned.
o
- object to be removed from this multiset.quantity
- quantity of elements to remove.
true
if the multiset got altered,
false
otherwise.public java.util.Set toSet()
public int setSize()
public int getQuantity(java.lang.Object o)
o
- element whose quantity is returned.
setQuantity(java.lang.Object, int)
public boolean setQuantity(java.lang.Object o, int quantity)
o
- element whose quantity gets set.quantity
- quantity of the specified element to be set.
true
if this multiset has been modified,
false
otherwise.getQuantity(java.lang.Object)
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.
c
- collection for which is checked whether this multiset is a
superset of or not.
true
if this multiset is a superset,
false
otherwise.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.
c
- collection for which is checked whether this multiset is a
subset of or not.
true
if this multiset is a subset,
false
otherwise.public boolean isDisjoint(java.util.Collection c)
true
if the specified collection has no common
elements with this multiset.
c
- collection to be checked for common elements.
true
if there are no common elements,
false
otherwise.public Multiset sum(java.util.Collection c)
Multiset
containing all elements that are present in this
multiset or in the specified collection. The quantities of equal
elements get added up.
c
- collection to be united with.
public Multiset union(java.util.Collection c)
Multiset
containing all elements that are present in this
multiset or in the specified collection. For equal elements, the
resulting quantity is the maximum of the two given quantities.
c
- collection to be united with.
public Multiset intersection(java.util.Collection c)
Multiset
containing all elements that are present in this
multiset as well as in the specified collection. For equal elements,
the resulting quantity is the minimum of the two given quantities.
c
- collection to be intersected with.
public Multiset difference(java.util.Collection c)
Multiset
containing all
elements that are present in this multiset but not in the specified
collection. The quantities of equal elements get subtracted.
c
- collection from which the difference is calculated.
public Multiset symmetricDifference(java.util.Collection c)
Multiset
containing all
elements that are present either in this multiset or in the specified
collection but not in both. The quantities of equal elements get
subtracted from each other (maximum minus minimum).
c
- collection from which the symmetric difference is calculated
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |