Documentation ¶
Overview ¶
Package bitops provides various utility functions and types for low level bit-twiddling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CLZ ¶
CLZ (Count Leading Zeros) counts the number of leading zeroes before the most significant bit in x that is set to 1. Calling CLZ(0) is undefined behavior.
func FFS ¶
FFS (Find First Set) returns the index of the least significant bit in x that is set to 1. Calling FFS(0) is undefined behavior.
func TwoBitArrayLength ¶
TwoBitArrayLength returns the length necessary for a byte slice to hold a TwoBitArray with count elements.
Types ¶
type TwoBitArray ¶
type TwoBitArray []byte
TwoBitArray is a bit array with two bits per entry. Within each byte in the TwoBitArray, position 0 points to the least significant 2 bits while position 3 points to the most significant 2 bits.
func (TwoBitArray) Get ¶
func (tba TwoBitArray) Get(pos uint) byte
Get returns the value of the 2 bits at the position pos in the lowest 2 bits of returned byte.
func (TwoBitArray) Set ¶
func (tba TwoBitArray) Set(pos uint, val byte)
Set sets the value of the 2 bits at position pos to the value of the lowest 2 bits in val.