What is more efficient in terms of memory and CPU usage — an array of boolean
s or a BitSet? Specific BitSet methods are not used, only get/set/clear (==, =, Arrays.fill respectively for an array).
Boolean[]
uses about 4-20 bytes per boolean value.boolean[]
uses about 1 byte per boolean value. BitSet
uses about 1 bit per boolean value.Memory size might not be an issue for you in which case boolean[] might be simpler to code.