mathCollection
Class MathCollections.SynchronizedMultiset

java.lang.Object
  extended bymathCollection.MathCollections.SynchronizedMultiset
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, Multiset, java.io.Serializable
Enclosing class:
MathCollections

static class MathCollections.SynchronizedMultiset
extends java.lang.Object
implements Multiset, java.io.Serializable, java.lang.Cloneable


Field Summary
private  Multiset myMultiset
           
private  java.lang.Object myMutex
           
 
Constructor Summary
(package private) MathCollections.SynchronizedMultiset(Multiset mus)
           
(package private) MathCollections.SynchronizedMultiset(Multiset mus, java.lang.Object mutex)
           
 
Method Summary
 boolean add(java.lang.Object o)
           
 boolean add(java.lang.Object o, int quantity)
          Adds the specified element quantity of times to this multiset.
 boolean addAll(java.util.Collection c)
           
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 Multiset difference(java.util.Collection c)
          Returns the asymmetric difference between this multiset and the specified collection.
 boolean equals(java.lang.Object o)
           
 int getQuantity(java.lang.Object o)
          Returns the number of times the specified element is present in this multiset.
 int hashCode()
           
 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 isEmpty()
           
 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.util.Iterator iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean remove(java.lang.Object o, int quantity)
          Removes the specified element quantity of times from this multiset if possible.
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 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.
 int size()
           
 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.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] o)
           
 java.util.Set toSet()
          Returns a 'flattened' version of this multiset in which every element of this multiset is present exactly once.
 java.lang.String toString()
           
 Multiset union(java.util.Collection c)
          Returns the union with the specified collection.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

myMultiset

private Multiset myMultiset

myMutex

private java.lang.Object myMutex
Constructor Detail

MathCollections.SynchronizedMultiset

MathCollections.SynchronizedMultiset(Multiset mus)

MathCollections.SynchronizedMultiset

MathCollections.SynchronizedMultiset(Multiset mus,
                                     java.lang.Object mutex)
Method Detail

size

public int size()
Specified by:
size in interface java.util.Collection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection

clear

public void clear()
Specified by:
clear in interface java.util.Collection

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection

toSet

public java.util.Set toSet()
Description copied from interface: Multiset
Returns a 'flattened' version of this multiset in which every element of this multiset is present exactly once.

Specified by:
toSet in interface Multiset
Returns:
the 'flattened' version of this multiset.

setSize

public int setSize()
Description copied from interface: Multiset
Returns the size of a 'flattened' version of this multiset in which every element of this multiset is present exactly once.

Specified by:
setSize in interface Multiset
Returns:
the size of the 'flattened' version of this multiset.

toString

public java.lang.String toString()

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] o)
Specified by:
toArray in interface java.util.Collection

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.util.Collection

clone

public java.lang.Object clone()

setQuantity

public boolean setQuantity(java.lang.Object o,
                           int quantity)
Description copied from interface: Multiset
Adjusts the number of times the specified element is present in this multiset to be the specified value.

Specified by:
setQuantity in interface Multiset
Parameters:
o - element whose quantity gets set.
quantity - quantity of the specified element to be set.
Returns:
true if this multiset has been modified, false otherwise.
See Also:
Multiset.getQuantity(java.lang.Object)

getQuantity

public int getQuantity(java.lang.Object o)
Description copied from interface: Multiset
Returns the number of times the specified element is present in this multiset.

Specified by:
getQuantity in interface Multiset
Parameters:
o - element whose quantity is returned.
Returns:
quantity of the specified element, 0 if it is not present.
See Also:
Multiset.setQuantity(java.lang.Object, int)

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection

add

public boolean add(java.lang.Object o,
                   int quantity)
Description copied from interface: Multiset
Adds the specified element quantity of times to this multiset. If quantity is negative or 0, false is returned.

Specified by:
add in interface Multiset
Parameters:
o - element to be added to this set.
quantity - quantity of elements to add.
Returns:
true if quantity is greater than 0, false otherwise

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection

remove

public boolean remove(java.lang.Object o,
                      int quantity)
Description copied from interface: Multiset
Removes the specified element quantity of times from this multiset if possible. If quantity is negative or 0, false is returned.

Specified by:
remove in interface Multiset
Parameters:
o - object to be removed from this multiset.
quantity - quantity of elements to remove.
Returns:
true if the multiset got altered, false otherwise.

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection

sum

public Multiset sum(java.util.Collection c)
Description copied from interface: Multiset
Returns the sum with the specified collection. This is a new Multiset containing all elements that are present in this multiset or in the specified collection. The quantities of equal elements get added up.

Specified by:
sum in interface Multiset
Parameters:
c - collection to be united with.
Returns:
the union with the specified collection.

union

public Multiset union(java.util.Collection c)
Description copied from interface: Multiset
Returns the union with the specified collection. This is a new 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.

Specified by:
union in interface Multiset
Parameters:
c - collection to be united with.
Returns:
the union with the specified collection.

intersection

public Multiset intersection(java.util.Collection c)
Description copied from interface: Multiset
Returns the intersection with the specified collection. This is a new 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.

Specified by:
intersection in interface Multiset
Parameters:
c - collection to be intersected with.
Returns:
the intersection with the specified collection.

difference

public Multiset difference(java.util.Collection c)
Description copied from interface: Multiset
Returns the asymmetric difference between this multiset and the specified collection. This is a new Multiset containing all elements that are present in this multiset but not in the specified collection. The quantities of equal elements get subtracted.

Specified by:
difference in interface Multiset
Parameters:
c - collection from which the difference is calculated.
Returns:
the difference with the specified collection.

symmetricDifference

public Multiset symmetricDifference(java.util.Collection c)
Description copied from interface: Multiset
Returns the symmetric difference between this multiset and the specified collection. This is a new 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).

Specified by:
symmetricDifference in interface Multiset
Parameters:
c - collection from which the symmetric difference is calculated
Returns:
the symmetric difference with the specified collection.

isDisjoint

public boolean isDisjoint(java.util.Collection c)
Description copied from interface: Multiset
Returns true if the specified collection has no common elements with this multiset.

Specified by:
isDisjoint in interface Multiset
Parameters:
c - collection to be checked for common elements.
Returns:
true if there are no common elements, false otherwise.

isSubset

public boolean isSubset(java.util.Collection c)
Description copied from interface: Multiset
Returns 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.

Specified by:
isSubset in interface Multiset
Parameters:
c - collection for which is checked whether this multiset is a subset of or not.
Returns:
true if this multiset is a subset, false otherwise.

isSuperset

public boolean isSuperset(java.util.Collection c)
Description copied from interface: Multiset
Returns 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.

Specified by:
isSuperset in interface Multiset
Parameters:
c - collection for which is checked whether this multiset is a superset of or not.
Returns:
true if this multiset is a superset, false otherwise.