|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<T>
edu.rice.cs.plt.collect.HashMultiset<T>
public class HashMultiset<T>
A HashMap-based implementation of Multiset. Values in the set
must be valid as keys in a HashMap. Care is taken so that most operations
are either performed in constant time or time linear to the number of unique
elements in the multiset (as opposed to time linear in the size of the multiset, which
may be significantly larger).
| Constructor Summary | |
|---|---|
HashMultiset()
Create an empty HashMultiset |
|
HashMultiset(java.util.Collection<? extends T> coll)
Create a HashMultiset containing all the elements of coll |
|
| Method Summary | |
|---|---|
boolean |
add(T val)
Add a single instance of val to the multiset. |
boolean |
add(T val,
int instances)
Add the given number of instances of val to the multiset. |
boolean |
addAll(java.util.Collection<? extends T> coll)
Add all the elements of coll to this multiset. |
PredicateSet<T> |
asSet()
Produce a set view of the multiset. |
void |
clear()
Remove all elements from the multiset |
boolean |
contains(java.lang.Object obj)
Whether the multiset contains at least one instance of obj. |
boolean |
containsAll(java.util.Collection<?> c)
Whether each element of the collection appears at least once in this multiset. |
int |
count(java.lang.Object value)
The number of times value appears in the multiset (if it does not appear,
the result is 0). |
boolean |
equals(java.lang.Object obj)
Compares two multisets. |
boolean |
hasFixedSize()
Whether the multiset can change size. |
int |
hashCode()
A hash code for the multiset, computed by summing the hash codes of each element in the iterator. |
boolean |
isEmpty()
Whether the multiset is empty. |
boolean |
isInfinite()
Whether the iterator has an infinite number of elements. |
boolean |
isStatic()
Whether the multiset will always contain the same values. |
boolean |
isSupersetOf(Multiset<?> m)
Whether each element ( elt) of s appears at least s.count(elt) times
in this multiset. |
java.util.Iterator<T> |
iterator()
An iterator for the multiset. |
boolean |
remove(java.lang.Object obj)
Remove a single instance of obj from the multiset, if one exists. |
boolean |
remove(java.lang.Object obj,
int instances)
Remove the given number of instances of obj from the multiset. |
boolean |
removeAll(java.util.Collection<?> coll)
Remove all the elements of coll from this multiset. |
boolean |
removeAllInstances(java.lang.Object obj)
Remove all instances of obj from the multiset |
boolean |
retainAll(java.util.Collection<?> coll)
Remove all the elements of this multiset except those contained in coll. |
int |
size()
The size of the multiset. |
int |
size(int bound)
The size of the multiset bounded by the given value. |
java.lang.String |
toString()
|
| Methods inherited from class java.util.AbstractCollection |
|---|
toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface edu.rice.cs.plt.collect.Multiset |
|---|
toArray, toArray |
| Constructor Detail |
|---|
public HashMultiset()
HashMultiset
public HashMultiset(java.util.Collection<? extends T> coll)
HashMultiset containing all the elements of coll
| Method Detail |
|---|
public int size()
Multiset
size in interface Multiset<T>size in interface SizedIterable<T>size in interface java.util.Collection<T>size in class java.util.AbstractCollection<T>public int size(int bound)
Multiset
size in interface Multiset<T>size in interface SizedIterable<T>bound - Maximum result. Assumed to be nonnegative.public boolean isInfinite()
Multiset
isInfinite in interface Multiset<T>isInfinite in interface SizedIterable<T>public boolean hasFixedSize()
Multiset
hasFixedSize in interface Multiset<T>hasFixedSize in interface SizedIterable<T>public boolean isStatic()
Multiset
isStatic in interface Multiset<T>isStatic in interface SizedIterable<T>public boolean isEmpty()
Multiset
isEmpty in interface Multiset<T>isEmpty in interface SizedIterable<T>isEmpty in interface java.util.Collection<T>isEmpty in class java.util.AbstractCollection<T>public boolean contains(java.lang.Object obj)
Multisetobj.
contains in interface Multiset<T>contains in interface java.util.Collection<T>contains in class java.util.AbstractCollection<T>public boolean containsAll(java.util.Collection<?> c)
Multiset
containsAll in interface Multiset<T>containsAll in interface java.util.Collection<T>containsAll in class java.util.AbstractCollection<T>public boolean isSupersetOf(Multiset<?> m)
Multisetelt) of s appears at least s.count(elt) times
in this multiset.
isSupersetOf in interface Multiset<T>public int count(java.lang.Object value)
Multisetvalue appears in the multiset (if it does not appear,
the result is 0). If the number is too large, Integer.MAX_VALUE may
be returned.
count in interface Multiset<T>public PredicateSet<T> asSet()
removeAllInstances(java.lang.Object) for that value. Adding to the set is not supported.
asSet in interface Multiset<T>public java.util.Iterator<T> iterator()
Multisetn instances of a
value, that value will appear n times during iteration. Invoking
remove on the iterator removes one instance.
iterator in interface Multiset<T>iterator in interface java.lang.Iterable<T>iterator in interface java.util.Collection<T>iterator in class java.util.AbstractCollection<T>public boolean add(T val)
Multisetval to the multiset.
add in interface Multiset<T>add in interface java.util.Collection<T>add in class java.util.AbstractCollection<T>true (indicating that the multiset was modified)
public boolean add(T val,
int instances)
Multisetval to the multiset.
add in interface Multiset<T>true (indicating that the multiset was modified)public boolean addAll(java.util.Collection<? extends T> coll)
Multisetcoll to this multiset. If the same value appears multiple
times in coll, it will appear multiple times in this multiset.
addAll in interface Multiset<T>addAll in interface java.util.Collection<T>addAll in class java.util.AbstractCollection<T>true iff the multiset was successfully modifiedpublic boolean remove(java.lang.Object obj)
Multisetobj from the multiset, if one exists.
remove in interface Multiset<T>remove in interface java.util.Collection<T>remove in class java.util.AbstractCollection<T>true iff the multiset was modified
public boolean remove(java.lang.Object obj,
int instances)
Multisetobj from the multiset. If
count(obj) <= instances, removes all instances of the given value.
remove in interface Multiset<T>true iff the multiset was modifiedpublic boolean removeAllInstances(java.lang.Object obj)
Multisetobj from the multiset
removeAllInstances in interface Multiset<T>true iff the multiset was modifiedpublic boolean removeAll(java.util.Collection<?> coll)
Multisetcoll from this multiset. If the same value appears
multiple times in coll, the same number of instances will be removed from
this multiset.
removeAll in interface Multiset<T>removeAll in interface java.util.Collection<T>removeAll in class java.util.AbstractCollection<T>true iff the multiset was modifiedpublic boolean retainAll(java.util.Collection<?> coll)
Multisetcoll. If
the same value appears multiple times in coll, at most that number of instances
will not be removed from this multiset.
retainAll in interface Multiset<T>retainAll in interface java.util.Collection<T>retainAll in class java.util.AbstractCollection<T>true iff the multiset was modifiedpublic void clear()
Multiset
clear in interface Multiset<T>clear in interface java.util.Collection<T>clear in class java.util.AbstractCollection<T>public java.lang.String toString()
toString in class java.util.AbstractCollection<T>public boolean equals(java.lang.Object obj)
Multiset
equals in interface Multiset<T>equals in interface java.util.Collection<T>equals in class java.lang.Objecttrue iff obj is a multiset with the same elements as thispublic int hashCode()
Multiset0; each null element has hash code 1.)
hashCode in interface Multiset<T>hashCode in interface java.util.Collection<T>hashCode in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||