Skip to content

Instantly share code, notes, and snippets.

@ericlagergren
Created May 13, 2016 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericlagergren/ed15d4625bc9c721416a8a923cbf4333 to your computer and use it in GitHub Desktop.
Save ericlagergren/ed15d4625bc9c721416a8a923cbf4333 to your computer and use it in GitHub Desktop.
type mask [ ... ]uint64
const (
word = 64
shift = 6
)
func (m mask) isSet(i int) bool {
return (m[i>>shift]>>(uint64(i)&(word-1)))&1 != 0
}
func (m *mask) set(i int) {
m[i>>shift] |= 1 << (uint64(i) & (word - 1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment