Class IntegerBitSet

java.lang.Object
adaa.analytics.rules.logic.representation.IntegerBitSet
All Implemented Interfaces:
Serializable, Iterable<Integer>, Collection<Integer>, Set<Integer>

public class IntegerBitSet extends Object implements Set<Integer>, Serializable
Upper-bounded set of integers represented internally as a bit vector. NOTE: While class implements Serializable interface, serialization/deserialization methods do nothing!
See Also:
  • Field Details

  • Constructor Details

    • IntegerBitSet

      public IntegerBitSet(int maxElement)
      Allocates words array for storing bits.
      Parameters:
      maxElement - Max element that can be stored in the set.
    • IntegerBitSet

      public IntegerBitSet(int maxElement, boolean fill)
      Allocates words array for storing bits.
      Parameters:
      maxElement - Max element that can be stored in the set.
  • Method Details

    • getMaxElement

      public int getMaxElement()
      Gets maxElement.
    • getRawTable

      public long[] getRawTable()
    • add

      public boolean add(Integer v)
      Adds new integer to the set (sets an appropriate bit).
      Specified by:
      add in interface Collection<Integer>
      Specified by:
      add in interface Set<Integer>
      Parameters:
      v - Integer to be added.
      Returns:
      Always true.
    • addAll

      public boolean addAll(Collection<? extends Integer> arg0)
      Adds all elements from a collection of integers to the set (sets appropriate bits). If given collection is another bit set, an optimized path is executed (logical operations on bit vectors).
      Specified by:
      addAll in interface Collection<Integer>
      Specified by:
      addAll in interface Set<Integer>
      Parameters:
      arg0 - Collection of integers to be added.
      Returns:
      Always true.
    • clear

      public void clear()
      Clears the set (resets all the bits).
      Specified by:
      clear in interface Collection<Integer>
      Specified by:
      clear in interface Set<Integer>
    • setAll

      public void setAll()
      Adds all elements up to maxElement (sets all bits).
    • setAll

      public void setAll(Collection<? extends Integer> arg0)
      Clears set and adds all elements from another collections.
    • negate

      public void negate()
      Generates complement of the set (negates all bits).
    • negate

      public void negate(IntegerBitSet output)
      Generates complement of the set (negates all bits).
    • contains

      public boolean contains(Object arg0)
      Checks if the set contains a given integer.
      Specified by:
      contains in interface Collection<Integer>
      Specified by:
      contains in interface Set<Integer>
      Parameters:
      arg0 - Integer to be checked.
      Returns:
      Test result.
    • containsAll

      public boolean containsAll(Collection<?> arg0)
      Check if the set contains all integers from a given collection. If given collection is another bit set, an optimized path is executed (logical operations on bit vectors).
      Specified by:
      containsAll in interface Collection<Integer>
      Specified by:
      containsAll in interface Set<Integer>
      Parameters:
      arg0 - Collection of integers to be checked.
      Returns:
      Test result.
    • isEmpty

      public boolean isEmpty()
      Checks if set is empty.
      Specified by:
      isEmpty in interface Collection<Integer>
      Specified by:
      isEmpty in interface Set<Integer>
      Returns:
      Test result.
    • iterator

      public Iterator<Integer> iterator()
      Gets a set iterator.
      Specified by:
      iterator in interface Collection<Integer>
      Specified by:
      iterator in interface Iterable<Integer>
      Specified by:
      iterator in interface Set<Integer>
      Returns:
      Set iterator.
    • remove

      public boolean remove(Object arg0)
      Removes an integer from the set (resets an appropriate bit).
      Specified by:
      remove in interface Collection<Integer>
      Specified by:
      remove in interface Set<Integer>
      Parameters:
      arg0 - Integer to be removed.
      Returns:
      Always true.
    • removeAll

      public boolean removeAll(Collection<?> arg0)
      Removes all elements from a collection of integers to the set (resets appropriate bits). If given collection is another bit set, an optimized path is executed (logical operations on bit vectors).
      Specified by:
      removeAll in interface Collection<Integer>
      Specified by:
      removeAll in interface Set<Integer>
      Parameters:
      arg0 - Collection of integers to be removed.
      Returns:
      Always true.
    • retainAll

      public boolean retainAll(Collection<?> arg0)
      Retain from the set all of its elements that are contained in the specified collection. If given collection is another bit set, an optimized path is executed (logical operations on bit vectors).
      Specified by:
      retainAll in interface Collection<Integer>
      Specified by:
      retainAll in interface Set<Integer>
      Parameters:
      arg0 - Collection with elements to be retained.
      Returns:
      Always true.
    • size

      public int size()
      Calculates set size.
      Specified by:
      size in interface Collection<Integer>
      Specified by:
      size in interface Set<Integer>
      Returns:
      Set size.
    • toString

      public String toString()
      Generates a text representation of the set.
      Overrides:
      toString in class Object
      Returns:
      Text representation.
    • calculateIntersectionSize

      public int calculateIntersectionSize(IntegerBitSet other)
      Calculates size of the interesection between this set and another one.
      Parameters:
      other - Other set.
      Returns:
      Intersection size.
    • calculateIntersectionSize

      public int calculateIntersectionSize(IntegerBitSet other1, IntegerBitSet other2)
      Calculates size of the interesection between this set and two other ones.
      Parameters:
      other1 - First other set.
      other2 - Second other set.
      Returns:
      Intersection size.
    • toArray

      public Object[] toArray()
      To be implemented.
      Specified by:
      toArray in interface Collection<Integer>
      Specified by:
      toArray in interface Set<Integer>
      Returns:
      Always null.
    • toArray

      public <T> T[] toArray(T[] arg0)
      To be implemented.
      Specified by:
      toArray in interface Collection<Integer>
      Specified by:
      toArray in interface Set<Integer>
      Parameters:
      arg0 - Unused argument.
      Returns:
      Always null.
    • clone

      public IntegerBitSet clone()
      Clones the set.
      Overrides:
      clone in class Object
      Returns:
      Deep copy of the set.
    • filteredCompare

      public boolean filteredCompare(IntegerBitSet arg0, IntegerBitSet arg1)
      Compares two other integer sets using this set as a mask.
      Parameters:
      arg0 - First set.
      arg1 - Second set.
      Returns:
      Value indicating if given two sets are equal after masking.