3
Set<Integer> one = new HashSet<>();4
Set<Integer> zero = new HashSet<>();6
public Bitset(int size) {8
for (int i = 0; i < size; i++) zero.add(i);11
public void fix(int idx) {16
public void unfix(int idx) {21
// swapping object's referrence is O(1)28
public boolean all() {29
return one.size() == size;32
public boolean one() {33
return one.size() >= 1;40
public String toString() {41
StringBuilder sb = new StringBuilder();42
for (int i = 0; i < size; i++) {43
if (one.contains(i)) sb.append("1");44
else if (zero.contains(i)) sb.append("0");