Class NumberSet

java.lang.Object
org.projog.clp.NumberSet

final class NumberSet extends Object
A set of long primitives.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final BitSet
     
    private final long
    The value that the first bit of the bitset represents.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    (package private)
    NumberSet(long start, long end)
    Constructs a new NumberSet containing all values within the specified range (inclusive).
    private
    NumberSet(long start, BitSet bitset)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int
    Returns the count of values set in this NumberSet.
    (package private) void
    clear(long not)
    Unsets (i.e.
    (package private) void
    clear(long fromValue, long toValue)
    Unsets all values between the given fromValue (inclusive) and toValue (inclusive).
    (package private) NumberSet
    Returns a new copy of this NumberSet.
    boolean
     
    (package private) boolean
    get(long value)
    Returns true if the given value is set, else false.
    int
     
    (package private) long
    nextSetValue(long value)
    Returns the value that occurs on or after the specified value.
    (package private) long
    previousSetValue(long value)
    Returns the value that occurs on or before the specified value.
    Returns all values contained in this set, in order, separated by commas and surrounded by braces.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • start

      private final long start
      The value that the first bit of the bitset represents.
    • bitset

      private final BitSet bitset
  • Constructor Details

    • NumberSet

      NumberSet(long start, long end)
      Constructs a new NumberSet containing all values within the specified range (inclusive).
      Parameters:
      start - the minimum value to be stored (inclusive)
      end - the maximum value to be stored (inclusive)
    • NumberSet

      private NumberSet(long start, BitSet bitset)
  • Method Details

    • copy

      NumberSet copy()
      Returns a new copy of this NumberSet.
    • get

      boolean get(long value)
      Returns true if the given value is set, else false.
    • clear

      void clear(long fromValue, long toValue)
      Unsets all values between the given fromValue (inclusive) and toValue (inclusive).

      NOTE: Unlike java.util.BitSet.clear(int, int) both values are *inclusive*.

    • clear

      void clear(long not)
      Unsets (i.e. remove from this NumberSet) the given value.
    • nextSetValue

      long nextSetValue(long value)
      Returns the value that occurs on or after the specified value.
      Parameters:
      value - fromIndex the index to start checking from (inclusive)
      Returns:
      the value that occurs on or after the specified value, or start - 1 is no such value
    • previousSetValue

      long previousSetValue(long value)
      Returns the value that occurs on or before the specified value.
      Parameters:
      value - fromIndex the index to start checking from (inclusive)
      Returns:
      the value that occurs on or after the specified value, or start - 1 is no such value
    • cardinality

      int cardinality()
      Returns the count of values set in this NumberSet.
    • toString

      public String toString()
      Returns all values contained in this set, in order, separated by commas and surrounded by braces.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object