// Copyright (C) 2019-2024, Lux Industries Inc. All rights reserved. // See the file LICENSE for licensing terms. package set import ( "fmt" "math/bits" ) // Bits64 is a set that can contain uints in the range [0, 64). All functions // are O(1). The zero value is the empty set. type Bits64 uint64 // Add [i] to the set of ints func (b *Bits64) Add(i uint) { *b |= 1 << i } // Union adds all the elements in [s] to this set func (b *Bits64) Union(s Bits64) { *b |= s } // Intersection takes the intersection of [s] with this set func (b *Bits64) Intersection(s Bits64) { *b &= s } // Difference removes all the elements in [s] from this set func (b *Bits64) Difference(s Bits64) { *b &^= s } // Remove [i] from the set of ints func (b *Bits64) Remove(i uint) { *b &^= 1 << i } // Clear removes all elements from this set func (b *Bits64) Clear() { *b = 0 } // Contains returns true if [i] was previously added to this set func (b Bits64) Contains(i uint) bool { return b&(1<