Class HashMultiset<E>

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

    public final class HashMultiset<E>
    extends AbstractMapBasedMultiset<E>
    Multiset implementation backed by a HashMap.
    Since:
    2.0
    See Also:
    Serialized Form
    • Constructor Detail

      • HashMultiset

        private HashMultiset()
      • HashMultiset

        private HashMultiset​(int distinctElements)
    • Method Detail

      • create

        public static <E> HashMultiset<E> create()
        Creates a new, empty HashMultiset using the default initial capacity.
      • create

        public static <E> HashMultiset<E> create​(int distinctElements)
        Creates a new, empty HashMultiset with the specified expected number of distinct elements.
        Parameters:
        distinctElements - the expected number of distinct elements
        Throws:
        java.lang.IllegalArgumentException - if distinctElements is negative
      • create

        public static <E> HashMultiset<E> create​(java.lang.Iterable<? extends E> elements)
        Creates a new HashMultiset containing the specified elements.

        This implementation is highly efficient when elements is itself a Multiset.

        Parameters:
        elements - the elements that the multiset should contain
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream stream)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException