Skip to content
Advertisement

Tag: bitset

BitSet only grows with true bits and not false?

Currently with Java version “11.0.3” 2019-04-16 LTS on a Linux host (but would expect 8+ compatibility): in the context of computing a picture in order to send a binary bitmap to some hardware that only knows a 1-bit depth of display, I am using the BitSet for the first time and I get some disappointing results: while populating the Bitset

How to flip all the bits in Java BitSet while preserving its length

How can I flip all the bits in a Java BitSet, while preserving its length? For example, given the following BitSet: Is there a simple method to flip all the bits, while preserving the BitSet length (6, in the above example)? I would like to get: Answer BitSet has a flip(from, to) method, which allows you to flip bits in

Where do we use BitSet and why do we use it in java?

I just found out that there is BitSet in java. There are already arrays and similar data structures. Where can BitSet be used? Answer As the above answer only explains what a BitSet is, I am providing here an answer of how I use BitSet and why. At first, I did not knew that the BitSet construct exists. I have

Advertisement