fix bitset bugs

This commit is contained in:
Tnze
2022-05-28 01:48:36 +08:00
parent 29ce03be31
commit 02dd436014
6 changed files with 30 additions and 25 deletions

View File

@ -59,9 +59,13 @@ func (b *BitSet) And(other *BitSet) *BitSet {
}
func (b *BitSet) AndNot(other BitSet) *BitSet {
result := BitSet{values: make([]uint, max(len(b.values), len(other.values)))}
result := BitSet{values: make([]uint, len(b.values))}
for i := range b.values {
result.values[i] = b.values[i] & ^other.values[i]
if i < len(other.values) {
result.values[i] = b.values[i] & ^other.values[i]
} else {
result.values[i] = b.values[i]
}
}
return &result
}