bits

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package bits provides operations on bit arrays.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[I constraints.Integer](data []byte, n I) int

Get returns the value of the n'th bit (0 or 1).

func Ones

func Ones(data []byte) iter.Seq[int]

Ones iterates over the indexes of bits whose values are 1.

func Set

func Set[I constraints.Integer](data []byte, n I, value bool)

Set sets the n'th bit to 1 or 0 for values of true or false respectively.

func Set0

func Set0[I constraints.Integer](data []byte, n I)

Set0 sets the n'th bit in data to 0.

func Set1

func Set1[I constraints.Integer](data []byte, n I)

Set1 sets the n'th bit in data to 1.

func Sum

func Sum(data []byte) int

Sum returns the number of bits that have a value of 1.

func Zeros

func Zeros(data []byte) iter.Seq[int]

Zeros iterates over the indexes of bits whose values are 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL