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
      void add(T key)
      Put key to the MultiSet once.
      void add(T key, int n)
       
      void addAll(Collection<T> keys)
      Put all keys contained in key into the MultiSet once.
      void addAll(Collection<T> keys, int n)
       
      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 remove(T key)
      Remove key from the MultiSet once.
      void removeAll(Collection<? extends T> key)
       
      void removeAllN(Collection<? extends T> key, int n)
       
      void removeAllOccurences(Collection<? extends T> key)
       
      void removeN(T key, int n)
      Remove key from the MultiSet once.
      void removeOccurences(T key)
      Remove all occurrences of key.
    • Method Detail

      • add

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

        void add(T key,
                 int n)
      • addAll

        void addAll(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.
      • removeAll

        void removeAll(Collection<? extends T> key)
      • 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.
      • removeAllN

        void removeAllN(Collection<? extends T> key,
                        int n)
      • removeOccurences

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

        void removeAllOccurences(Collection<? extends T> key)
      • 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.