SetBit sets a bit at the given index to true.
(k uint64)
| 85 | |
| 86 | // SetBit sets a bit at the given index to true. |
| 87 | func (ba *bitArray) SetBit(k uint64) error { |
| 88 | if k >= ba.Capacity() { |
| 89 | return OutOfRangeError(k) |
| 90 | } |
| 91 | |
| 92 | if !ba.anyset { |
| 93 | ba.lowest = k |
| 94 | ba.highest = k |
| 95 | ba.anyset = true |
| 96 | } else { |
| 97 | if k < ba.lowest { |
| 98 | ba.lowest = k |
| 99 | } else if k > ba.highest { |
| 100 | ba.highest = k |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | i, pos := getIndexAndRemainder(k) |
| 105 | ba.blocks[i] = ba.blocks[i].insert(pos) |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | // GetBit returns a bool indicating if the value at the given |
| 110 | // index has been set. |
nothing calls this directly
no test coverage detected