Discover Packages
github.com/Stebalien/go-bitfield
package
module
Version:
v0.0.1
Opens a new window with list of versions in this module.
Published: May 20, 2019
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 5
Opens a new window with list of known importers.
README
README
¶
go-bitfield
This is a simple bitfield package that's about 2-3x faster than using big.Int
s
from the standard library. It also has a better interface (and, e.g., supports
counting ones).
Expand ▾
Collapse ▴
Documentation
¶
Bitfield is, well, a bitfield.
FromBytes constructs a new bitfield from a serialized bitfield.
NewBitfield creates a new fixed-sized Bitfield (allocated up-front).
Panics if size is not a multiple of 8.
Bit returns the ith bit.
Panics if the bit is out of bounds.
Bytes returns the Bitfield as a byte string.
This function *does not* copy.
Ones returns the number of bits set.
OnesAfter returns the number of bits set *after* this bit.
OnesBefore returns the number of bits set *before* this bit.
SetBit sets the ith bit.
Panics if the bit is out of bounds.
SetBytes sets the bits to the given byte array.
Panics if 'b' is larger than the bitfield.
UnsetBit unsets the ith bit.
Panics if the bit is out of bounds.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.