org.apache.commons.collections.bag

Class SynchronizedSortedBag

Implemented Interfaces:
Bag, Collection, Bag, Serializable, SortedBag

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.

Version:
$Revision: 1.8 $ $Date: 2004/06/03 22:02:12 $
Author:
Stephen Colebourne
Since:
Commons Collections 3.0

Field Summary

Fields inherited from class org.apache.commons.collections.collection.SynchronizedCollection

collection, lock

Constructor Summary

SynchronizedSortedBag(Bag bag, Object lock)
Constructor that wraps (not copies).
SynchronizedSortedBag(SortedBag bag)
Constructor that wraps (not copies).

Method Summary

Comparator
comparator()
static SortedBag
decorate(SortedBag bag)
Factory method to create a synchronized sorted bag.
Object
first()
protected SortedBag
getSortedBag()
Gets the bag being decorated.
Object
last()

Methods inherited from class org.apache.commons.collections.bag.SynchronizedBag

add, decorate, getBag, getCount, remove, uniqueSet

Methods inherited from class org.apache.commons.collections.collection.SynchronizedCollection

add, addAll, clear, contains, containsAll, decorate, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString

Constructor Details

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

SynchronizedSortedBag

protected SynchronizedSortedBag(SortedBag bag)
Constructor that wraps (not copies).
Parameters:
bag - the bag to decorate, must not be null

Method Details

comparator

public Comparator comparator()
Specified by:
comparator in interface SortedBag

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

first

public Object first()
Specified by:
first in interface SortedBag

getSortedBag

protected SortedBag getSortedBag()
Gets the bag being decorated.
Returns:
the decorated bag

last

public Object last()
Specified by:
last in interface SortedBag

Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.