Class MultiSet<T>

java.lang.Object
adaa.analytics.rules.logic.representation.MultiSet<T>
Type Parameters:
T - Type of elements stored in a set.
All Implemented Interfaces:
Serializable, Iterable<T>

public class MultiSet<T> extends Object implements Iterable<T>, Serializable
Generic class representing a multiset.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Map<T,Integer>
    Collection storing elements with their multiplicity
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(T v)
    Adds an element to the multiset (increments multiplicity by 1).
    boolean
    add(T v, int count)
    Adds an element to the multiset given number of times (increments multiplicity by this number).
    void
     
    boolean
    Verifies the multiset contains a given element.
    int
    Gets multiplicity of a specified element.
    Multiset iterator.
    int
    Gets multisize of the multiset.
    void
    Removes element from the multiset.
    int
    Gets size of the multiset.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • map

      protected Map<T,Integer> map
      Collection storing elements with their multiplicity
    • totalCount

      protected int totalCount
  • Constructor Details

    • MultiSet

      public MultiSet()
  • Method Details

    • contains

      public boolean contains(Object v)
      Verifies the multiset contains a given element.
      Parameters:
      v - Elements to be verified.
      Returns:
      Verification result.
    • add

      public boolean add(T v)
      Adds an element to the multiset (increments multiplicity by 1).
      Parameters:
      v - Element to be added.
      Returns:
      Should be ignored - always true.
    • add

      public boolean add(T v, int count)
      Adds an element to the multiset given number of times (increments multiplicity by this number).
      Parameters:
      v - Element to be added.
      count - Multiplicity of the element being added.
      Returns:
      Should be ignored - always true.
    • getCount

      public int getCount(T v)
      Gets multiplicity of a specified element.
      Parameters:
      v - Element to be found in the set.
      Returns:
      Multiplicity of the element (0 if it doesn't exist).
    • remove

      public void remove(Object v)
      Removes element from the multiset.
      Parameters:
      v - Elements to be removed.
    • clear

      public void clear()
    • size

      public int size()
      Gets size of the multiset.
      Returns:
      Number of unique elements in the multiset.
    • multisize

      public int multisize()
      Gets multisize of the multiset.
      Returns:
      Number of all elements in the multiset.
    • iterator

      public Iterator<T> iterator()
      Multiset iterator.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      Iterator to unique multiset elements.