E - the type of the elements in the bag.public final class CopyOnWriteArrayBag<E> extends AbstractBag<E> implements ConcurrentBag<E>, Serializable
ArrayBag based on CopyOnWriteArrayList.
This implementation provides a predictable iteration order which is the order
in which elements were inserted into the bag (insertion-order). Also, this
implementation accepts null elements.| Constructor and Description |
|---|
CopyOnWriteArrayBag()
Creates a new empty
CopyOnWriteArrayBag. |
CopyOnWriteArrayBag(Collection<? extends E> c)
Creates a new
CopyOnWriteArrayBag using the elements
contained in the given Collection. |
CopyOnWriteArrayBag(E... elements)
Creates a new
CopyOnWriteArrayBag using the elements
contained in the given array. |
CopyOnWriteArrayBag(Iterable<? extends E> i)
Creates a new
CopyOnWriteArrayBag using the elements
contained in the given Iterable. |
CopyOnWriteArrayBag(Iterator<? extends E> i)
Creates a new
CopyOnWriteArrayBag using the elements
contained in the given Iterator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
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) |
boolean |
containsAll(Collection<?> c) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
count, equals, hashCodetoStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitequals, hashCodepublic CopyOnWriteArrayBag()
CopyOnWriteArrayBag.public CopyOnWriteArrayBag(Collection<? extends E> c)
CopyOnWriteArrayBag using the elements
contained in the given Collection.c - the collection to use to populate the created bag.NullPointerException - if c is null.public CopyOnWriteArrayBag(Iterable<? extends E> i)
CopyOnWriteArrayBag using the elements
contained in the given Iterable.i - the iterable to use to populate the created bag.NullPointerException - if i is null.public CopyOnWriteArrayBag(Iterator<? extends E> i)
CopyOnWriteArrayBag using the elements
contained in the given Iterator.i - the iterator to use to populate the created bag.NullPointerException - if i is null.public CopyOnWriteArrayBag(E... elements)
CopyOnWriteArrayBag using the elements
contained in the given array.elements - the elements to use to populate the created bag.NullPointerException - if elements is null.public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public int size()
size in interface Collection<E>size in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in class AbstractCollection<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in class AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in class AbstractCollection<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in class AbstractCollection<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty 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.Copyright © 2012–2015. All rights reserved.