pivot.collections.concurrent
Class SynchronizedCollection<T>
java.lang.Object
pivot.collections.concurrent.SynchronizedCollection<T>
- All Implemented Interfaces:
- java.lang.Iterable<T>, Collection<T>
- Direct Known Subclasses:
- SynchronizedList, SynchronizedMap, SynchronizedSet
public abstract class SynchronizedCollection<T>
- extends java.lang.Object
- implements Collection<T>
Abstract base class for synchronized collection wrappers.
NOTE In order to guarantee thread-safe access, all access to the backing
collection must be via the synchronized wrapper.
- Author:
- gbrown
Method Summary |
java.util.Comparator<T> |
getComparator()
Returns the collection's sort order. |
java.util.Iterator<T> |
iterator()
NOTE Callers must manually synchronize on the SynchronizedCollection
instance to ensure thread safety during iteration. |
void |
setComparator(java.util.Comparator<T> comparator)
Sets the collection's sort order, re-ordering the collection's contents
and ensuring that new entries preserve the sort order. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
collection
protected Collection<T> collection
SynchronizedCollection
public SynchronizedCollection(Collection<T> collection)
getComparator
public java.util.Comparator<T> getComparator()
- Description copied from interface:
Collection
- Returns the collection's sort order.
- Specified by:
getComparator
in interface Collection<T>
- Returns:
- The comparator used to order elements in the collection, or null
if the sort order is undefined.
- See Also:
Collection.setComparator(Comparator)
setComparator
public void setComparator(java.util.Comparator<T> comparator)
- Description copied from interface:
Collection
- Sets the collection's sort order, re-ordering the collection's contents
and ensuring that new entries preserve the sort order.
- Specified by:
setComparator
in interface Collection<T>
- Parameters:
comparator
- The comparator used to order elements in the collection, or null if the
collection is unsorted.
iterator
public java.util.Iterator<T> iterator()
- NOTE Callers must manually synchronize on the SynchronizedCollection
instance to ensure thread safety during iteration.
- Specified by:
iterator
in interface java.lang.Iterable<T>