Class MultiIntSet

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Integer>

    public class MultiIntSet
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.Integer>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected gnu.trove.map.hash.TIntLongHashMap cardinalities  
      protected long size  
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiIntSet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(int element)  
      boolean add​(int element, long cardinality)  
      boolean addAll​(gnu.trove.TIntCollection collection)  
      boolean addAll​(java.util.Collection<java.lang.Integer> collection)
      Add each element of the collection, each with cardinality 1.
      boolean addAll​(java.util.Collection<java.lang.Integer> collection, long cardinality)
      Add each element of the collection, each with cardinality as given.
      boolean addAll​(MultiIntSet collection)  
      void clear()  
      MultiIntSet clone()  
      boolean contains​(int a)  
      MultiIntSet copy()  
      void empty()  
      boolean equals​(java.lang.Object obj)  
      long getCardinalityOf​(int e)  
      int getElementWithHighestCardinality()
      Get an element with the highest cardinality of all elements.
      int hashCode()  
      boolean isEmpty()  
      java.util.Iterator<java.lang.Integer> iterator()
      Iterator over the elements of the multiset as if it were a set.
      boolean remove​(int element)  
      boolean remove​(int element, long cardinality)  
      int setSize()  
      long size()  
      int[] sortByCardinality()
      Returns a list of the elements, sorted by their cardinality.
      gnu.trove.set.TIntSet toSet()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • cardinalities

        protected gnu.trove.map.hash.TIntLongHashMap cardinalities
      • size

        protected long size
    • Constructor Detail

      • MultiIntSet

        public MultiIntSet()
    • Method Detail

      • clear

        public void clear()
      • add

        public boolean add​(int element)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • add

        public boolean add​(int element,
                           long cardinality)
      • remove

        public boolean remove​(int element,
                              long cardinality)
      • remove

        public boolean remove​(int element)
      • addAll

        public boolean addAll​(java.util.Collection<java.lang.Integer> collection)
        Add each element of the collection, each with cardinality 1.
        Parameters:
        collection -
        Returns:
      • addAll

        public boolean addAll​(java.util.Collection<java.lang.Integer> collection,
                              long cardinality)
        Add each element of the collection, each with cardinality as given.
        Parameters:
        collection -
        cardinality -
        Returns:
      • addAll

        public boolean addAll​(gnu.trove.TIntCollection collection)
      • addAll

        public boolean addAll​(MultiIntSet collection)
      • empty

        public void empty()
      • size

        public long size()
        Returns:
        The total number of elements in the multiset. Use setSize() for the number of distinct elements in the multiset.
      • isEmpty

        public boolean isEmpty()
      • setSize

        public int setSize()
      • toSet

        public gnu.trove.set.TIntSet toSet()
      • contains

        public boolean contains​(int a)
      • getCardinalityOf

        public long getCardinalityOf​(int e)
      • iterator

        public java.util.Iterator<java.lang.Integer> iterator()
        Iterator over the elements of the multiset as if it were a set. Get cardinalities using getCardinality().
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>
      • getElementWithHighestCardinality

        public int getElementWithHighestCardinality()
        Get an element with the highest cardinality of all elements.
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public MultiIntSet clone()
        Overrides:
        clone in class java.lang.Object
      • sortByCardinality

        public int[] sortByCardinality()
        Returns a list of the elements, sorted by their cardinality.
        Returns: