Interface Multiset<E>

  • Type Parameters:
    E - the element type
    All Superinterfaces:
    java.util.Collection<E>, java.lang.Iterable<E>
    All Known Implementing Classes:
    HashMultiset

    public interface Multiset<E>
    extends java.util.Collection<E>
    A collection which permits duplicates, and provides methods adding/removing several counts of an element.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(E element, int n)
      Add n counts of an element.
      int count​(java.lang.Object element)  
      java.util.Set<E> getDistinctElements()  
      int remove​(java.lang.Object element, int n)
      Remove up to n counts of an element.
      • Methods inherited from interface java.util.Collection

        add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Method Detail

      • add

        void add​(E element,
                 int n)
        Add n counts of an element.
        Parameters:
        element - the element to add
        n - how many to add
      • remove

        int remove​(java.lang.Object element,
                   int n)
        Remove up to n counts of an element.
        Parameters:
        element - the element the remove
        n - how many to remove
        Returns:
        the number of elements removed
      • count

        int count​(java.lang.Object element)
      • getDistinctElements

        java.util.Set<E> getDistinctElements()