Class 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:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version
      See Also:
  • Constructor Details

    • SynchronizedSortedMultiSet

      protected SynchronizedSortedMultiSet(SortedMultiSet<E> multiset)
      Constructor that wraps (not copies).
      Parameters:
      multiset - The multiset to decorate, must not be null
      Throws:
      NullPointerException - if multiset is null
    • SynchronizedSortedMultiSet

      protected SynchronizedSortedMultiSet(SortedMultiSet<E> multiset, Object lock)
      Constructor that wraps (not copies).
      Parameters:
      multiset - The multiset to decorate, must not be null
      lock - 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

      public Comparator<? super E> comparator()
      Description copied from interface: SortedMultiSet
      Returns the comparator associated with this sorted multiset, or null if it uses its elements' natural ordering.
      Specified by:
      comparator in interface SortedMultiSet<E>
      Returns:
      The comparator in use, or null if natural ordering.
    • decorated

      protected SortedMultiSet<E> decorated()
      Gets the multiset being decorated.
      Overrides:
      decorated in class SynchronizedMultiSet<E>
      Returns:
      The decorated multiset
    • first

      public E first()
      Description copied from interface: SortedMultiSet
      Returns the first (lowest) member.
      Specified by:
      first in interface SortedMultiSet<E>
      Returns:
      The first element in the sorted multiset.
    • last

      public E last()
      Description copied from interface: SortedMultiSet
      Returns the last (highest) member.
      Specified by:
      last in interface SortedMultiSet<E>
      Returns:
      The last element in the sorted multiset.