org.apache.commons.collections.bag

Class SynchronizedSortedBag

public class SynchronizedSortedBag extends SynchronizedBag implements 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: Commons Collections 3.0

Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $

Author: Stephen Colebourne

Constructor Summary
protected SynchronizedSortedBag(SortedBag bag)
Constructor that wraps (not copies).
protected SynchronizedSortedBag(Bag bag, Object lock)
Constructor that wraps (not copies).
Method Summary
Comparatorcomparator()
static SortedBagdecorate(SortedBag bag)
Factory method to create a synchronized sorted bag.
Objectfirst()
protected SortedBaggetSortedBag()
Gets the bag being decorated.
Objectlast()

Constructor Detail

SynchronizedSortedBag

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

SynchronizedSortedBag

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

Method Detail

comparator

public Comparator comparator()

decorate

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

first

public Object first()

getSortedBag

protected SortedBag getSortedBag()
Gets the bag being decorated.

Returns: the decorated bag

last

public Object last()
Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.