Class NumberSet


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

      Fields 
      Modifier and Type Field Description
      private java.util.BitSet bitset  
      private long start
      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, java.util.BitSet bitset)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) int cardinality()
      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 copy()
      Returns a new copy of this NumberSet.
      boolean equals​(java.lang.Object o)  
      (package private) boolean get​(long value)
      Returns true if the given value is set, else false.
      int hashCode()  
      (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.
      java.lang.String toString()
      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 Detail

      • start

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

        private final java.util.BitSet bitset
    • Constructor Detail

      • 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,
                          java.util.BitSet bitset)
    • Method Detail

      • 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 java.lang.String toString()
        Returns all values contained in this set, in order, separated by commas and surrounded by braces.
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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