Answer the question
In order to leave comments, you need to log in
How to efficiently store large bit masks?
Sometimes you need []bit for algorithmic problems with memory requirements . bool uses byte and not bit (on my machine) //Prints 1000. And that's in bytes not bits https://golang.org/pkg/unsafe/#Sizeof
There was an interesting " math/bits " in stdlib, but it limited in size to uint64 and has no trivial get(n) set(n) methods .
Advise where to dig. The code is not required, approaches are enough. Is it possible to sculpt your type from []uint64 and hang it with methods? fmt.Println(unsafe.Sizeof([1000]bool{}))
Answer the question
In order to leave comments, you need to log in
You can use https://godoc.org/github.com/golang-collections/go...
Or write your own implementation based on []byte, for example. Shifts or masks to get the bit you need.
https://goplay.space/#aBmYRHvEg6u
I think that's how it should be, probably. if I understand the question correctly. just compare bit by bit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question