public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements SortedBag<E>
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.
lock
Modifier | Constructor and Description |
---|---|
protected |
SynchronizedSortedBag(Bag<E> bag,
Object lock)
Constructor that wraps (not copies).
|
protected |
SynchronizedSortedBag(SortedBag<E> bag)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
Comparator<? super E> |
comparator()
Returns the comparator associated with this sorted set, or null
if it uses its elements' natural ordering.
|
E |
first()
Returns the first (lowest) member.
|
protected SortedBag<E> |
getSortedBag()
Gets the bag being decorated.
|
E |
last()
Returns the last (highest) member.
|
static <E> SynchronizedSortedBag<E> |
synchronizedSortedBag(SortedBag<E> bag)
Factory method to create a synchronized sorted bag.
|
add, getBag, getCount, remove, synchronizedBag, uniqueSet
add, addAll, clear, contains, containsAll, decorated, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, synchronizedCollection, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
protected SynchronizedSortedBag(SortedBag<E> bag)
bag
- the bag to decorate, must not be nullIllegalArgumentException
- if bag is nullprotected SynchronizedSortedBag(Bag<E> bag, Object lock)
bag
- the bag to decorate, must not be nulllock
- the lock to use, must not be nullIllegalArgumentException
- if bag is nullpublic static <E> SynchronizedSortedBag<E> synchronizedSortedBag(SortedBag<E> bag)
E
- the type of the elements in the bagbag
- the bag to decorate, must not be nullIllegalArgumentException
- if bag is nullprotected SortedBag<E> getSortedBag()
public E first()
SortedBag
public E last()
SortedBag
public Comparator<? super E> comparator()
SortedBag
comparator
in interface SortedBag<E>
Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.