Top Description Fields Constructors Methods
org.apache.commons.collections4.bag

public Class SynchronizedSortedBag<E>

extends SynchronizedBag<E>
implements SortedBag<E>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.SortedBag, org.apache.commons.collections4.Bag, java.util.Collection, java.lang.Iterable
Type Parameters
<E>
the type of elements in this bag
Imports
java.util.Comparator, org.apache.commons.collections4.Bag, .SortedBag

Decorates another SortedBag 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.

Since
3.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
SynchronizedSortedBag(final SortedBag<E>
the bag to decorate, must not be null
bag
)

Constructor that wraps (not copies).

protected
SynchronizedSortedBag(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).

Method Summary

Modifier and TypeMethod and Description
public synchronized Comparator<? super E>
comparator()

Implements org.apache.commons.collections4.SortedBag.comparator.

Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
public synchronized E
first()

Implements org.apache.commons.collections4.SortedBag.first.

Returns the first (lowest) member.
protected SortedBag<E>

Returns:

the decorated bag
getSortedBag
()

Gets the bag being decorated.

public synchronized E
last()

Implements org.apache.commons.collections4.SortedBag.last.

Returns the last (highest) member.
public static <
the type of the elements in the bag
E
>
SynchronizedSortedBag<E>

Returns:

a new synchronized SortedBag
synchronizedSortedBag
(final SortedBag<E>
the bag to decorate, must not be null
bag
)

Factory method to create a synchronized sorted bag.

Inherited from org.apache.commons.collections4.bag.SynchronizedBag:
addequalsgetBaggetCounthashCoderemovesynchronizedBaguniqueSet

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.bag.SynchronizedBag.serialVersionUID.

Serialization version

Constructor Detail

SynchronizedSortedBagback to summary
protected SynchronizedSortedBag(final SortedBag<E> bag)

Constructor that wraps (not copies).

Parameters
bag:SortedBag<E>

the bag to decorate, must not be null

Exceptions
NullPointerException:
if bag is null
SynchronizedSortedBagback to summary
protected SynchronizedSortedBag(final Bag<E> bag, final Object lock)

Constructor that wraps (not copies).

Parameters
bag:Bag<E>

the bag to decorate, must not be null

lock:Object

the lock to use, must not be null

Exceptions
NullPointerException:
if bag or lock is null

Method Detail

comparatorback to summary
public synchronized Comparator<? super E> comparator()

Implements org.apache.commons.collections4.SortedBag.comparator.

Doc from org.apache.commons.collections4.SortedBag.comparator.

Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.

Returns:Comparator<? super E>

the comparator in use, or null if natural ordering

Annotations
@Override
firstback to summary
public synchronized E first()

Implements org.apache.commons.collections4.SortedBag.first.

Doc from org.apache.commons.collections4.SortedBag.first.

Returns the first (lowest) member.

Returns:E

the first element in the sorted bag

Annotations
@Override
getSortedBagback to summary
protected SortedBag<E> getSortedBag()

Gets the bag being decorated.

Returns:SortedBag<E>

the decorated bag

lastback to summary
public synchronized E last()

Implements org.apache.commons.collections4.SortedBag.last.

Doc from org.apache.commons.collections4.SortedBag.last.

Returns the last (highest) member.

Returns:E

the last element in the sorted bag

Annotations
@Override
synchronizedSortedBagback to summary
public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(final SortedBag<E> bag)

Factory method to create a synchronized sorted bag.

Parameters
<E>
the type of the elements in the bag
bag:SortedBag<E>

the bag to decorate, must not be null

Returns:SynchronizedSortedBag<E>

a new synchronized SortedBag

Exceptions
NullPointerException:
if bag is null
Since
4.0