Class TransformedSortedMultiSet<E>

Type Parameters:
E - The type held in the multiset.
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, MultiSet<E>, SortedMultiSet<E>

public class TransformedSortedMultiSet<E> extends TransformedMultiSet<E> implements SortedMultiSet<E>
Decorates another SortedMultiSet to transform objects that are added.

The add and setCount methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.

Since:
4.6.0
See Also:
  • Constructor Details

    • TransformedSortedMultiSet

      protected TransformedSortedMultiSet(SortedMultiSet<E> multiset, Transformer<? super E,? extends E> transformer)
      Constructor that wraps (not copies).

      If there are any elements already in the multiset being decorated, they are NOT transformed.

      Parameters:
      multiset - The multiset to decorate, must not be null.
      transformer - The transformer to use for conversion, must not be null.
      Throws:
      NullPointerException - if multiset or transformer is null.
  • Method Details

    • transformedSortedMultiSet

      public static <E> TransformedSortedMultiSet<E> transformedSortedMultiSet(SortedMultiSet<E> multiset, Transformer<? super E,? extends E> transformer)
      Factory method to create a transforming sorted multiset that will transform existing contents of the specified sorted multiset.

      If there are any elements already in the multiset being decorated, they will be transformed by this method. Contrast this with transformingSortedMultiSet(SortedMultiSet, Transformer).

      Type Parameters:
      E - The type of the elements in the multiset.
      Parameters:
      multiset - The multiset to decorate, must not be null.
      transformer - The transformer to use for conversion, must not be null.
      Returns:
      A new transformed SortedMultiSet.
      Throws:
      NullPointerException - if multiset or transformer is null.
    • transformingSortedMultiSet

      public static <E> TransformedSortedMultiSet<E> transformingSortedMultiSet(SortedMultiSet<E> multiset, Transformer<? super E,? extends E> transformer)
      Factory method to create a transforming sorted multiset.

      If there are any elements already in the multiset being decorated, they are NOT transformed. Contrast this with transformedSortedMultiSet(SortedMultiSet, Transformer).

      Type Parameters:
      E - The type of the elements in the multiset.
      Parameters:
      multiset - The multiset to decorate, must not be null.
      transformer - The transformer to use for conversion, must not be null.
      Returns:
      A new transformed SortedMultiSet.
      Throws:
      NullPointerException - if multiset or transformer 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.
    • 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.
    • getSortedMultiSet

      Gets the decorated sorted multiset.
      Returns:
      The decorated 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.