-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl. AppendTo and AsSlice #195
Conversation
huch, wait a moment, a panic test isn't working as expected |
ready for merge, or drop it if you don't like |
// AppendTo appends all set bits to buf and returns the (maybe extended) buf. | ||
// | ||
// See also [BitSet.AsSlice] and [BitSet.NextSetMany]. | ||
func (b *BitSet) AppendTo(buf []uint) []uint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, we can overflow uint. It would be nice to mention that what happens if someone has a gigantic bitset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
@gaissmai Please see my comment. |
I'll will push an update in a few minutes |
I'm not a native speaker, maybe you will polish my new docstring. edited: not a native english speaker ;) |
@gaissmai Let me explain what I meant. On a 32-bit system, uint maxes out at 2**32 - 1. Meanwhile, the bitset can represent values between 0 and (2**32 - 1) * 64. Right? So It won't overflow in practice. But it is worth saying why. Or, at least, just say 'won't overflow in practice' as a comment. |
hm, yes, but this is not different to NextSet and NetxSetMany |
Correct. Let me merge this and I will add comments. |
added AsSlice() and AppendTo() as convenience functions, if you like it, merge it, otherwise drop the PR
thanks for bitset