Class SynchronizedSortedMultiSet<E>
java.lang.Object
org.apache.commons.collections4.collection.SynchronizedCollection<E>
org.apache.commons.collections4.multiset.SynchronizedMultiSet<E>
org.apache.commons.collections4.multiset.SynchronizedSortedMultiSet<E>
- Type Parameters:
E- The type held in the multiset.
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,MultiSet<E>,SortedMultiSet<E>
public class SynchronizedSortedMultiSet<E>
extends SynchronizedMultiSet<E>
implements SortedMultiSet<E>
Decorates another
SortedMultiSet to synchronize its behavior
for a multithreaded environment.
Methods are synchronized, then forwarded to the decorated multiset. Iterators must be separately synchronized around the loop.
- Since:
- 4.6.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.commons.collections4.MultiSet
MultiSet.Entry<E> -
Field Summary
Fields inherited from class org.apache.commons.collections4.collection.SynchronizedCollection
lock -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSynchronizedSortedMultiSet(SortedMultiSet<E> multiset) Constructor that wraps (not copies).protectedSynchronizedSortedMultiSet(SortedMultiSet<E> multiset, Object lock) Constructor that wraps (not copies). -
Method Summary
Modifier and TypeMethodDescriptionComparator<? super E> Returns the comparator associated with this sorted multiset, or null if it uses its elements' natural ordering.protected SortedMultiSet<E> Gets the multiset being decorated.first()Returns the first (lowest) member.last()Returns the last (highest) member.static <E> SynchronizedSortedMultiSet<E> synchronizedSortedMultiSet(SortedMultiSet<E> multiset) Factory method to create a synchronized sorted multiset.Methods inherited from class org.apache.commons.collections4.multiset.SynchronizedMultiSet
add, entrySet, equals, getCount, hashCode, remove, setCount, synchronizedMultiSet, uniqueSetMethods inherited from class org.apache.commons.collections4.collection.SynchronizedCollection
add, addAll, clear, contains, containsAll, forEach, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, synchronizedCollection, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
addAll, clear, contains, isEmpty, parallelStream, removeIf, spliterator, stream, toArray, toArray
-
Constructor Details
-
SynchronizedSortedMultiSet
Constructor that wraps (not copies).- Parameters:
multiset- The multiset to decorate, must not be null- Throws:
NullPointerException- if multiset is null
-
SynchronizedSortedMultiSet
Constructor that wraps (not copies).- Parameters:
multiset- The multiset to decorate, must not be nulllock- The lock to use, must not be null- Throws:
NullPointerException- if multiset or lock is null
-
-
Method Details
-
synchronizedSortedMultiSet
public static <E> SynchronizedSortedMultiSet<E> synchronizedSortedMultiSet(SortedMultiSet<E> multiset) Factory method to create a synchronized sorted multiset.- Type Parameters:
E- The type of the elements in the multiset- Parameters:
multiset- The multiset to decorate, must not be null- Returns:
- A new synchronized SortedMultiSet
- Throws:
NullPointerException- if multiset is null
-
comparator
Description copied from interface:SortedMultiSetReturns the comparator associated with this sorted multiset, or null if it uses its elements' natural ordering.- Specified by:
comparatorin interfaceSortedMultiSet<E>- Returns:
- The comparator in use, or null if natural ordering.
-
decorated
Gets the multiset being decorated.- Overrides:
decoratedin classSynchronizedMultiSet<E>- Returns:
- The decorated multiset
-
first
Description copied from interface:SortedMultiSetReturns the first (lowest) member.- Specified by:
firstin interfaceSortedMultiSet<E>- Returns:
- The first element in the sorted multiset.
-
last
Description copied from interface:SortedMultiSetReturns the last (highest) member.- Specified by:
lastin interfaceSortedMultiSet<E>- Returns:
- The last element in the sorted multiset.
-