Class Multiset_HashMapImpl<T>

  • Type Parameters:
    T - element class, must have consistent equals() and hashCode() methods
    All Implemented Interfaces:
    Serializable, Cloneable, Map<T,​Integer>, Multiset<T>

    public class Multiset_HashMapImpl<T>
    extends HashMap<T,​Integer>
    implements Multiset<T>
    A set of unsorted elements with multiple occurences. This is an exact implementation of multisets: - Two multisets like {a, a, b} and {a, b, a} are equal - and there is no ordering relation between elements. As such, the implementation can be based on HashMaps which also have no defined sort order. This has the following consequences: - HashMaps are usually faster than SortedMaps - without defined sort order, it makes no sense to demand entries to be Comparable, neither for the multisets themselves because an ordering of the multisets would depend on one for their entries. - output of these multisets will usually look a bit ugly
    Author:
    Tilman Neumann
    See Also:
    Serialized Form
    • Constructor Detail

      • Multiset_HashMapImpl

        public Multiset_HashMapImpl()
        Constructor for an empty multiset.
      • Multiset_HashMapImpl

        public Multiset_HashMapImpl​(Collection<T> values)
        Constructor from an ordinary collection.
        Parameters:
        values -
      • Multiset_HashMapImpl

        public Multiset_HashMapImpl​(T[] values)
        Constructor from a value array.
        Parameters:
        values -
      • Multiset_HashMapImpl

        public Multiset_HashMapImpl​(Multiset<T> original)
        Copy constructor.
        Parameters:
        original -