public class

SynchronizedSortedBag

extends SynchronizedBag
implements SortedBag
java.lang.Object
   ↳ org.apache.commons.collections.collection.SynchronizedCollection
     ↳ org.apache.commons.collections.bag.SynchronizedBag
       ↳ org.apache.commons.collections.bag.SynchronizedSortedBag

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class org.apache.commons.collections.collection.SynchronizedCollection
Protected Constructors
SynchronizedSortedBag(SortedBag bag)
Constructor that wraps (not copies).
SynchronizedSortedBag(Bag bag, Object lock)
Constructor that wraps (not copies).
Public Methods
synchronized Comparator comparator()
Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
static SortedBag decorate(SortedBag bag)
Factory method to create a synchronized sorted bag.
synchronized Object first()
Returns the first (lowest) member.
synchronized Object last()
Returns the last (highest) member.
Protected Methods
SortedBag getSortedBag()
Gets the bag being decorated.
[Expand]
Inherited Methods
From class org.apache.commons.collections.bag.SynchronizedBag
From class org.apache.commons.collections.collection.SynchronizedCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface org.apache.commons.collections.Bag
From interface org.apache.commons.collections.SortedBag

Protected Constructors

protected SynchronizedSortedBag (SortedBag bag)

Constructor that wraps (not copies).

Parameters
bag the bag to decorate, must not be null
Throws
IllegalArgumentException if bag is null

protected SynchronizedSortedBag (Bag bag, Object lock)

Constructor that wraps (not copies).

Parameters
bag the bag to decorate, must not be null
lock the lock to use, must not be null
Throws
IllegalArgumentException if bag is null

Public Methods

public synchronized Comparator comparator ()

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

Returns
  • the comparator in use, or null if natural ordering

public static SortedBag decorate (SortedBag bag)

Factory method to create a synchronized sorted bag.

Parameters
bag the bag to decorate, must not be null
Returns
  • a new synchronized SortedBag
Throws
IllegalArgumentException if bag is null

public synchronized Object first ()

Returns the first (lowest) member.

Returns
  • the first element in the sorted bag

public synchronized Object last ()

Returns the last (highest) member.

Returns
  • the last element in the sorted bag

Protected Methods

protected SortedBag getSortedBag ()

Gets the bag being decorated.

Returns
  • the decorated bag