Class Multiset<T>

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

    public final class Multiset<T>
    extends java.util.AbstractCollection<T>
    A Multiset is a set that allows for duplicate elements. Two Multisets are equal if they contain the same unique elements and if each unique element has as many occurrences in both multisets. Iteration order is not specified.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<T,​java.lang.Integer> map  
      private int size  
    • Constructor Summary

      Constructors 
      Constructor Description
      Multiset()
      Create an empty Multiset.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T e)  
      void clear()  
      boolean contains​(java.lang.Object o)  
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      java.util.Iterator<T> iterator()  
      boolean remove​(java.lang.Object o)  
      int size()  
      • Methods inherited from class java.util.AbstractCollection

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

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

        parallelStream, removeIf, spliterator, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • map

        private final java.util.Map<T,​java.lang.Integer> map
      • size

        private int size
    • Constructor Detail

      • Multiset

        public Multiset()
        Create an empty Multiset.
    • Method Detail

      • iterator

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

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

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T>
        Overrides:
        clear in class java.util.AbstractCollection<T>
      • add

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

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<T>
        Overrides:
        remove in class java.util.AbstractCollection<T>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<T>
        Overrides:
        contains in class java.util.AbstractCollection<T>
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<T>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<T>
        Overrides:
        hashCode in class java.lang.Object