public abstract class AbstractMultiSet<E> extends java.util.AbstractCollection<E> implements MultiSet<E>
MultiSet
interface to simplify the
creation of subclass implementations.MultiSet.Entry<E>
Modifier and Type | Method and Description |
---|---|
boolean |
add(E object)
Adds one copy of the specified object to the MultiSet.
|
int |
add(E object,
int occurrences)
Adds a number of occurrences of the specified object to the MultiSet.
|
void |
clear()
Clears the multiset removing all elements from the entrySet.
|
boolean |
contains(java.lang.Object object)
Determines if the multiset contains the given element.
|
java.util.Set<MultiSet.Entry<E>> |
entrySet()
Returns an unmodifiable view of the entries of this multiset.
|
boolean |
equals(java.lang.Object object)
Compares this MultiSet to another object.
|
int |
getCount(java.lang.Object object)
Returns the number of occurrence of the given element in this multiset by
iterating over its entrySet.
|
int |
hashCode()
Gets a hash code for the MultiSet compatible with the definition of equals.
|
java.util.Iterator<E> |
iterator()
Gets an iterator over the multiset elements.
|
boolean |
remove(java.lang.Object object)
Removes one occurrence of the given object from the MultiSet.
|
int |
remove(java.lang.Object object,
int occurrences)
Removes a number of occurrences of the specified object from the MultiSet.
|
boolean |
removeAll(java.util.Collection<?> coll)
Remove all occurrences of all elements from this MultiSet represented
in the given collection.
|
int |
setCount(E object,
int count)
Sets the number of occurrences of the specified object in the MultiSet
to the given count.
|
int |
size()
Returns the number of elements in this multiset.
|
java.lang.String |
toString()
Implement a toString() method suitable for debugging.
|
java.util.Set<E> |
uniqueSet()
Returns a view of the unique elements of this multiset.
|
addAll, containsAll, isEmpty, retainAll, toArray, toArray
containsAll, retainAll
public int size()
public int getCount(java.lang.Object object)
public int setCount(E object, int count)
MultiSet
If the provided count is zero, the object will be removed from the
MultiSet.uniqueSet()
.
public boolean contains(java.lang.Object object)
public java.util.Iterator<E> iterator()
public boolean add(E object)
MultiSet
If the object is already in the MultiSet.uniqueSet()
then increment its
count as reported by MultiSet.getCount(Object)
. Otherwise add it to the
MultiSet.uniqueSet()
and report its count as 1.
public int add(E object, int occurrences)
MultiSet
If the object is already in the MultiSet.uniqueSet()
then increment its
count as reported by MultiSet.getCount(Object)
. Otherwise add it to the
MultiSet.uniqueSet()
and report its count as occurrences
.
public void clear()
public boolean remove(java.lang.Object object)
MultiSet
If the number of occurrences after this operations is reduced
to zero, the object will be removed from the MultiSet.uniqueSet()
.
public int remove(java.lang.Object object, int occurrences)
MultiSet
If the number of occurrences to remove is greater than the actual number of occurrences in the multiset, the object will be removed from the multiset.
remove
in interface MultiSet<E>
object
- the object to removeoccurrences
- the number of occurrences to remove, may be zero,
in which case no change is made to the multisetpublic boolean removeAll(java.util.Collection<?> coll)
MultiSet
public java.util.Set<E> uniqueSet()
public java.util.Set<MultiSet.Entry<E>> entrySet()
public boolean equals(java.lang.Object object)
MultiSet
This MultiSet equals another object if it is also a MultiSet that contains the same number of occurrences of the same elements.
public int hashCode()
MultiSet
(e==null ? 0 : e.hashCode()) ^ noOccurances)
.public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"