Class HashMultiset<E>

  • All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, Multiset<E>

    public final class HashMultiset<E>
    extends java.util.AbstractCollection<E>
    implements Multiset<E>
    • Constructor Summary

      Constructors 
      Constructor Description
      HashMultiset()  
      HashMultiset​(java.util.Collection<E> source)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E element)  
      void add​(E element, int n)
      Add n counts of an element.
      int count​(java.lang.Object element)  
      java.util.Set<E> getDistinctElements()  
      java.util.Iterator<E> iterator()  
      boolean remove​(java.lang.Object element)  
      int remove​(java.lang.Object element, int n)
      Remove up to n counts of an element.
      int size()  
      • Methods inherited from class java.util.AbstractCollection

        addAll, clear, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

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

        forEach
    • Constructor Detail

      • HashMultiset

        public HashMultiset()
      • HashMultiset

        public HashMultiset​(java.util.Collection<E> source)
    • Method Detail

      • add

        public void add​(E element,
                        int n)
        Description copied from interface: Multiset
        Add n counts of an element.
        Specified by:
        add in interface Multiset<E>
        Parameters:
        element - the element to add
        n - how many to add
      • add

        public boolean add​(E element)
        Specified by:
        add in interface java.util.Collection<E>
        Overrides:
        add in class java.util.AbstractCollection<E>
      • remove

        public int remove​(java.lang.Object element,
                          int n)
        Description copied from interface: Multiset
        Remove up to n counts of an element.
        Specified by:
        remove in interface Multiset<E>
        Parameters:
        element - the element the remove
        n - how many to remove
        Returns:
        the number of elements removed
      • remove

        public boolean remove​(java.lang.Object element)
        Specified by:
        remove in interface java.util.Collection<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in class java.util.AbstractCollection<E>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
      • count

        public int count​(java.lang.Object element)
        Specified by:
        count in interface Multiset<E>