Interface MultiSet<T>

  • Type Parameters:
    T - the type of elements.
    All Superinterfaces:
    Iterable<T>
    All Known Implementing Classes:
    HashMultiSet


    public interface MultiSet<T>
    extends Iterable<T>
    A set which essentially is not a set since each key has an associated number of occurrences.
    • Method Summary

      Modifier and Type Method and Description
      boolean contains(T key)
      Test whether key is present in this MultiSet.
      Set<T> keySet()
      Get the set of keys in this MultiSet.
      int occurences(T key)
      Get the number of times the element key is present in this MultiSet.
      void put(T key)
      Put key to the MultiSet once.
      void put(T key, int howOften)
       
      void putAll(Collection<T> keys)
      Put all keys contained in key into the MultiSet once.
      void remove(T key)
      Remove key from the MultiSet once.
      void removeAll(T key)
      Remove all occurrences of key.
      void removeN(T key, int n)
      Remove key from the MultiSet once.
    • Method Detail

      • put

        void put(T key)
        Put key to the MultiSet once.
        Parameters:
        key - the element to add.
      • put

        void put(T key,
                 int howOften)
      • putAll

        void putAll(Collection<T> keys)
        Put all keys contained in key into the MultiSet once.
        Parameters:
        keys - a collection of keys.
      • remove

        void remove(T key)
        Remove key from the MultiSet once.
        Parameters:
        key - the element to remove.
      • removeN

        void removeN(T key,
                     int n)
        Remove key from the MultiSet once.
        Parameters:
        key - the element to remove.
        n - the number of times to remove the specified element.
      • removeAll

        void removeAll(T key)
        Remove all occurrences of key.
        Parameters:
        key - the element to remove.
      • occurences

        int occurences(T key)
        Get the number of times the element key is present in this MultiSet.
        Parameters:
        key - the element queried.
        Returns:
        the number of occurrences of key in this MultiSet.
      • contains

        boolean contains(T key)
        Test whether key is present in this MultiSet.
        Parameters:
        key - the element queried.
        Returns:
        whether key is contained in this MultiSet.
      • keySet

        Set<T> keySet()
        Get the set of keys in this MultiSet.
        Returns:
        the set of keys.