bitfield

package module
v0.0.0-...-7d3f8f8 Latest Latest
Warning

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

Go to latest
Published: May 3, 2017 License: Unlicense Imports: 0 Imported by: 3

README

bitfield

Simple bitfields in golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitField

type BitField []byte

BitField type

func New

func New(n int) BitField

New returns a new BitField of at least n bits, all 0s

func NewFromUint32

func NewFromUint32(n uint32) BitField

NewFromUint32 returns a new BitField of 4 bytes, with n initial value

func NewFromUint64

func NewFromUint64(n uint64) BitField

NewFromUint64 returns a new BitField of 8 bytes, with n initial value

func (BitField) ANDMask

func (b BitField) ANDMask(m BitField)

ANDMask performs an AND operation between b and m, storing result in b. If b is smaller than m, the extra bits of m are ignored (b isn't enlarged).

func (BitField) Clear

func (b BitField) Clear(i uint32)

Clear sets bit i to 0

func (BitField) ClearAll

func (b BitField) ClearAll()

ClearAll sets all BitField values to 0

func (BitField) Flip

func (b BitField) Flip(i uint32)

Flip toggles the value of bit i

func (BitField) FlipAll

func (b BitField) FlipAll()

FlipAll flips all the BitField bits (1's compliment)

func (BitField) ORMask

func (b BitField) ORMask(m BitField)

ORMask performs an OR operation between b and m, storing result in b. If b is smaller than m, the extra bits of m are ignored (b isn't enlarged).

func (BitField) Set

func (b BitField) Set(i uint32)

Set sets bit i to 1

func (BitField) SetAll

func (b BitField) SetAll()

SetAll sets all BitField bits to 1

func (BitField) Size

func (b BitField) Size() int

Size returns BitField size in bytes (not bits)

func (BitField) Test

func (b BitField) Test(i uint32) bool

Test returns true/false on bit i value

func (BitField) ToUint32

func (b BitField) ToUint32() uint32

ToUint32 returns the lowest 4 bytes as a uint32 NO BOUNDS CHECKING, ENSURE BitField is at least 4 bytes long

func (BitField) ToUint32Safe

func (b BitField) ToUint32Safe() uint32

ToUint32Safe returns the lowest 4 bytes as a uint32

func (BitField) ToUint64

func (b BitField) ToUint64() uint64

ToUint64 returns the lowest 8 bytes as a uint64 NO BOUNDS CHECKING, ENSURE BitField is at least 8 bytes long

func (BitField) ToUint64Safe

func (b BitField) ToUint64Safe() uint64

ToUint64Safe returns the lowest 8 bytes as a uint64

func (BitField) XORMask

func (b BitField) XORMask(m BitField)

XORMask performs an XOR operation between b and m, storing result in b. If b is smaller than m, the extra bits of m are ignored (b isn't enlarged).

Jump to

Keyboard shortcuts

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