Skip to content

Instantly share code, notes, and snippets.

@vporoshok
Created June 4, 2017 18:01
Show Gist options
  • Select an option

  • Save vporoshok/2a6a1455107ccf7b22b498199cd29f66 to your computer and use it in GitHub Desktop.

Select an option

Save vporoshok/2a6a1455107ccf7b22b498199cd29f66 to your computer and use it in GitHub Desktop.
package graph
type labels []uint8
func newLabels(n int) labels {
l := make(labels, n/8+1)
for i := range l {
l[i] &= 0
}
return l
}
func (l labels) check(n int) bool {
return l[n/8]&(uint8(1)<<uint(n%8)) > 0
}
func (l labels) set(n int) {
l[n/8] |= uint8(1) << uint(n%8)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment