BitArray

Works with JDK 1.1 and forward


Depending on JVM, Java boolean arrays use full byte or even more for each boolean. Since boolean could be saved to one bit, there is obvious big waste of memory. Also Java array's length can't be longer than Integer.MAX_VALUE (or little bit less actually, seems to depend on environment).

BitArray is simple class to store huge boolean arrays using just one bit per boolean. Class contains also fast methods to set all or chosen range to true or false, and also method to count true values in array.


Source

BitArray.java (as .txt)