Bag to synchronize its behaviour
for a multi-threaded environment.
Methods are synchronized, then forwarded to the decorated bag. Iterators must be separately synchronized around the loop.
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | SynchronizedBag.SynchronizedBagSet
Synchronized Set for the Bag class. |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | SynchronizedBag(final Bag<E>
the bag to decorate, must not be null bag)Constructor that wraps (not copies). |
| protected | SynchronizedBag(final Bag<E>
the bag to decorate, must not be null bag, final Object the lock to use, must not be null lock)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(final E
the object to add object, final int the number of copies to add count)Implements org. nCopies copies of the specified object to the Bag.
|
| public boolean | equals(final Object
object to be compared for equality with this collection object)Overrides org. Implements java. |
| protected Bag | |
| public int | getCount(final Object
the object to search for object)Implements org. |
| public int | hashCode()
Overrides org. Implements java. |
| public boolean | remove(final Object
the object to remove object, final int the number of copies to remove count)Implements org. nCopies copies of the specified object from the Bag.
|
| public static < the type of the elements in the bag E> SynchronizedBag | Returns: a new synchronized Bagthe bag to decorate, must not be null bag)Factory method to create a synchronized bag. |
| public Set | uniqueSet()
Implements org. Set of unique elements in the Bag.
|
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| SynchronizedBag | back to summary |
|---|---|
| protected SynchronizedBag(final Bag<E> bag) Constructor that wraps (not copies).
| |
| SynchronizedBag | back to summary |
|---|---|
| protected SynchronizedBag(final Bag<E> bag, final Object lock) Constructor that wraps (not copies).
| |
| add | back to summary |
|---|---|
| public boolean add(final E object, final int count) Implements org. Doc from org. Adds
If the object is already in the
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object object) Overrides org. Implements java. Doc from java. Compares the specified object with this collection for equality.
While the
The general contract for the | |
| getBag | back to summary |
|---|---|
| protected Bag Gets the bag being decorated.
| |
| getCount | back to summary |
|---|---|
| public int getCount(final Object object) Implements org. Doc from org. Returns the number of occurrences (cardinality) of the given object currently in the bag. If the object does not exist in the bag, return 0. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Implements java. Doc from java. Returns the hash code value for this collection. While the
| |
| remove | back to summary |
|---|---|
| public boolean remove(final Object object, final int count) Implements org. Doc from org. Removes If the number of copies to remove is greater than the actual number of copies in the Bag, no error is thrown. | |
| synchronizedBag | back to summary |
|---|---|
| public static <E> SynchronizedBag Factory method to create a synchronized bag.
| |
| uniqueSet | back to summary |
|---|---|
| public Set Implements org. Doc from org. Returns a
Uniqueness constraints are the same as those in | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| pack-priv | SynchronizedBagSet(final Set<E>
the set to decorate set, final Object the lock to use, shared with the bag lock)Constructor. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| SynchronizedBagSet | back to summary |
|---|---|
| pack-priv SynchronizedBagSet(final Set<E> set, final Object lock) Constructor. | |