| Constructor and Description |
|---|
MyMultiset()
Crea un multiset vuoto.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(E element)
Adds a single occurrence of the specified element to this multiset.
|
int |
add(E element,
int occurrences)
Adds a number of occurrences of an element to this multiset.
|
void |
clear()
Removes all of the elements from this multiset.
|
boolean |
contains(java.lang.Object element)
Determines whether this multiset contains the specified element.
|
int |
count(java.lang.Object element)
Returns the number of occurrences of an element in this multiset.
|
java.util.Set<E> |
elementSet()
Returns the set of distinct elements contained in this multiset.
|
boolean |
equals(java.lang.Object obj)
Compares the specified object with this multiset for equality.
|
int |
hashCode()
Returns the hash code for this multiset.
|
boolean |
isEmpty()
Returns true if this multiset contains no elements.
|
java.util.Iterator<E> |
iterator()
Returns an iterator for the multiset.
|
boolean |
remove(java.lang.Object element)
Removes a single occurrence of the specified element from this
multiset, if present.
|
int |
remove(java.lang.Object element,
int occurrences)
Removes a number of occurrences of the specified element from this
multiset.
|
int |
setCount(E element,
int count)
Adds or removes the necessary occurrences of an element such that the
element attains the desired count.
|
int |
size()
Returns the total number of elements in this multiset counting all the
occurrences.
|
public int size()
Multiset[1,2,3,1,4].size() must return five by
counting the two occurrences of 1.public int count(java.lang.Object element)
Multisetpublic int add(E element, int occurrences)
Multisetpublic void add(E element)
Multisetpublic int remove(java.lang.Object element,
int occurrences)
Multisetremove in interface Multiset<E>element - the element to conditionally remove occurrences ofoccurrences - the number of occurrences of the element to
remove. May be zero, in which case no change will
be made.public boolean remove(java.lang.Object element)
Multisetpublic int setCount(E element, int count)
Multisetpublic java.util.Set<E> elementSet()
MultisetelementSet in interface Multiset<E>public java.util.Iterator<E> iterator()
Multisetpublic boolean contains(java.lang.Object element)
Multisetpublic void clear()
Multisetpublic boolean isEmpty()
Multisetpublic int hashCode()
Multisetpublic boolean equals(java.lang.Object obj)
Multisettrue if the given object is also a multiset and contains equal
elements with equal counts, regardless of order.