MCPcopy Create free account
hub / github.com/careercup/CtCI-6th-Edition / set

Method set

Java/CtCILibrary/CtCILibrary/BitVector.java:45–55  ·  view source on GitHub ↗
(int i, boolean flag)

Source from the content-addressed store, hash-verified

43 }
44
45 public void set(int i, boolean flag) {
46 if (i >= 0 && i < length) {
47 int mask = ~(1 << i);
48 int b = vector[i / DATA_SIZE] & mask;
49 if (flag) {
50 vector[i / DATA_SIZE] = b | (1 << i);
51 } else {
52 vector[i / DATA_SIZE] = b;
53 }
54 }
55 }
56}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected