E - the type of the elements in the bag.public final class ConcurrentHashBag<E> extends AbstractBag<E> implements ConcurrentBag<E>, Serializable
HashBag based on ConcurrentHashMap.| Constructor and Description |
|---|
ConcurrentHashBag()
Creates a new empty
ConcurrentHashBag. |
ConcurrentHashBag(Collection<? extends E> c)
Creates a new
ConcurrentHashBag using the elements contained
in the given Collection. |
ConcurrentHashBag(E... elements)
Creates a new
ConcurrentHashBag using the elements contained
in the given array. |
ConcurrentHashBag(int initialCapacity)
Creates a new empty
ConcurrentHashBag having the given
initial capacity. |
ConcurrentHashBag(Iterable<? extends E> i)
Creates a new
ConcurrentHashBag using the elements contained
in the given Iterable. |
ConcurrentHashBag(Iterator<? extends E> i)
Creates a new
ConcurrentHashBag using the elements contained
in the given Iterator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
int |
addAllAbsent(Collection<? extends E> c)
Adds all of the elements in the specified collection that are not
already contained in this bag.
|
boolean |
addIfAbsent(E e)
Adds the given element to this bag if not already present.
|
void |
clear() |
boolean |
contains(Object o) |
int |
count(E e)
Returns the count of the given element in this bag.
|
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
equals, hashCodeaddAll, containsAll, isEmpty, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, isEmpty, toArray, toArraypublic ConcurrentHashBag()
ConcurrentHashBag.public ConcurrentHashBag(int initialCapacity)
ConcurrentHashBag having the given
initial capacity.initialCapacity - the bag's initial capacity.IllegalArgumentException - if initialCapacity < 0.public ConcurrentHashBag(Collection<? extends E> c)
ConcurrentHashBag using the elements contained
in the given Collection.c - the collection to use to populate the created bag.NullPointerException - if c is null or if it
contains a null reference.public ConcurrentHashBag(Iterable<? extends E> i)
ConcurrentHashBag using the elements contained
in the given Iterable.i - the iterable to use to populate the created bag.NullPointerException - if i is null or if it
contains a null reference.public ConcurrentHashBag(Iterator<? extends E> i)
ConcurrentHashBag using the elements contained
in the given Iterator.i - the iterator to use to populate the created bag.NullPointerException - if i is null or if it
contains a null reference.public ConcurrentHashBag(E... elements)
ConcurrentHashBag using the elements contained
in the given array.elements - the elements to use to populate the created bag.NullPointerException - if elements is null or
if it contains a null reference.public boolean add(E e)
add in interface Collection<E>add in class AbstractCollection<E>public int addAllAbsent(Collection<? extends E> c)
ConcurrentBagaddAllAbsent in interface ConcurrentBag<E>c - the collection containing elements to be added to this bag.public boolean addIfAbsent(E e)
ConcurrentBagaddIfAbsent in interface ConcurrentBag<E>e - the element to be added to this bag, if absent.true if the element has been added.public void clear()
clear in interface Collection<E>clear in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in class AbstractCollection<E>public int count(E e)
Bagpublic Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in class AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in class AbstractCollection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in class AbstractCollection<E>public int size()
size in interface Collection<E>size in class AbstractCollection<E>Copyright © 2012–2015. All rights reserved.