Find file
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (56 sloc) 1.91 KB


Bit set implementation to support bit sets in Java with a Long.MAX_VALUE number of bits. java.util.BitSet uses an int for addressing bits, this limits the number of bits to 2^31.

The implementation uses a list of BitSet objects to store the bits and performs an offset calculation to manage the bits. This allows the implementation to be pure Java, though a native implementation (C/JNI) would be more efficient in both memory and time.


import com.github.kyleburton.JBit;

public class Example {
  public static void main (String [] args ) {
    JBit bitSet = new JBit();
    bitSet.set( 2L * (long)Integer.MAX_VALUE );
    for (int ii = -5; ii <= 5; ++ii ) {
      long jj = (long)ii + (2L * (long)Integer.MAX_VALUE);
      System.out.println("set?[" + ii + "/" + jj + "]" + bitSet.get(jj));

Maven Repository


<!-- or -->
  :repositories {"kyleburton-releases" ""}
  ;; or:
  :repositories {"kyleburton-snapshots" ""}


   [com.github.kyleburton/JBit "1.0.0"]







Copyright © 2011 RelayNetwork

Distributed under the Eclipse Public License, the same as Clojure.