Class BitSet64

java.lang.Object
Jcg.util.BitSet64
All Implemented Interfaces:
BitSetInterface

public class BitSet64 extends Object implements BitSetInterface
An implementation of a bit-vector (using memory words on 64 bits)
Author:
Luca Castelli Aleardi (older version by Yonik)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long[]
     
    private int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BitSet64(boolean[] A)
    Constructs a BitSet64 from an input array of booleans
    BitSet64(int numBits)
    Constructs an OpenBitSet large enough to hold numBits.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bits2words(int numBits)
    returns the number of 64 bit words it would take to hold numBits
    int
    Returns the size of the bitset (number of words)
    void
    clear(int index)
    Clears a bit.
    boolean
    get(int index)
    Returns true or false for the specified bit index.
    int
    getBit(int index)
    Returns 1 if the bit is set, 0 if not.
    long[]
    Expert: returns the long[] storing the bits
    void
    set(int index)
    Sets the bit at the specified index.
    int
    Returns the size of the bitset (number of words)
    boolean[]
    return an array of booleans corresponding to the bit-vector
    void
    toBoolean(boolean[] array)
    Convert the BitSet64 into an array of booleans
     

    Methods inherited from class java.lang.Object

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

    • numBits

      private int numBits
    • bits

      private long[] bits
    • wlen

      private int wlen
  • Constructor Details

    • BitSet64

      public BitSet64(int numBits)
      Constructs an OpenBitSet large enough to hold numBits.
      Parameters:
      numBits -
    • BitSet64

      public BitSet64(boolean[] A)
      Constructs a BitSet64 from an input array of booleans
      Parameters:
      A - an array of booleans
  • Method Details

    • size

      public int size()
      Returns the size of the bitset (number of words)
      Specified by:
      size in interface BitSetInterface
    • bitSize

      public int bitSize()
      Returns the size of the bitset (number of words)
      Specified by:
      bitSize in interface BitSetInterface
    • getBits

      public long[] getBits()
      Expert: returns the long[] storing the bits
    • get

      public boolean get(int index)
      Returns true or false for the specified bit index. The index should be less than the OpenBitSet size
      Specified by:
      get in interface BitSetInterface
    • getBit

      public int getBit(int index)
      Returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size
      Specified by:
      getBit in interface BitSetInterface
    • set

      public void set(int index)
      Sets the bit at the specified index. The index should be less than the OpenBitSet size.
      Specified by:
      set in interface BitSetInterface
    • clear

      public void clear(int index)
      Clears a bit. The index should be less than the OpenBitSet size.
      Specified by:
      clear in interface BitSetInterface
    • bits2words

      public static int bits2words(int numBits)
      returns the number of 64 bit words it would take to hold numBits
    • toBoolean

      public boolean[] toBoolean()
      return an array of booleans corresponding to the bit-vector
    • toBoolean

      public void toBoolean(boolean[] array)
      Convert the BitSet64 into an array of booleans
      Parameters:
      array - an input array of booleans
    • toString

      public String toString()
      Overrides:
      toString in class Object