E - The type of element being stored.public final class CopyOnWriteMultiset<E>
extends java.lang.Object
implements java.lang.Iterable<E>
This class is thread-safe using the same method as CopyOnWriteArrayList. Mutation methods cause the underlying data to be
copied. elementSet() and iterator() return snapshots that are unaffected by
subsequent mutations.
Iterating directly on this class reveals duplicate elements. Unique elements can be accessed
via elementSet(). Iteration order for both of these is not defined.
| 构造器和说明 |
|---|
CopyOnWriteMultiset() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
add(E element)
Adds
element to the multiset. |
java.util.Set<E> |
elementSet()
Returns a snapshot of the unique elements currently in this multiset.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over a snapshot of all the elements currently in this multiset (including
duplicates).
|
void |
remove(E element)
Removes
element from the multiset. |
public void add(E element)
element to the multiset.element - The element to be added.public void remove(E element)
element from the multiset.element - The element to be removed.public java.util.Set<E> elementSet()
Changes to the underlying multiset are not reflected in the returned value.
public java.util.Iterator<E> iterator()
Changes to the underlying multiset are not reflected in the returned value.
iterator 在接口中 java.lang.Iterable<E>