Class LinkedHashMultiset<E>

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

    public final class LinkedHashMultiset<E>
    extends AbstractMapBasedMultiset<E>
    A Multiset implementation with predictable iteration order. Its iterator orders elements according to when the first occurrence of the element was added. When the multiset contains multiple instances of an element, those instances are consecutive in the iteration order. If all occurrences of an element are removed, after which that element is added to the multiset, the element will appear at the end of the iteration.

    See the Guava User Guide article on Multiset.

    Since:
    2.0
    See Also:
    Serialized Form
    • Constructor Detail

      • LinkedHashMultiset

        private LinkedHashMultiset()
      • LinkedHashMultiset

        private LinkedHashMultiset​(int distinctElements)
    • Method Detail

      • create

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

        public static <E> LinkedHashMultiset<E> create​(int distinctElements)
        Creates a new, empty LinkedHashMultiset 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> LinkedHashMultiset<E> create​(java.lang.Iterable<? extends E> elements)
        Creates a new LinkedHashMultiset 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