bitfield64

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: GPL-3.0 Imports: 2 Imported by: 1

README

Coverage

bitfield64

Bitfield for up to 64bits in length

Description

Package bitfield64 is a simple, quick stack-based bit-field manipulator package of 64 bits (or less) in length. If you need more bits you either need to create an array of bitfield64-s (and stay on the stack) or need to switch to the heap-based bitfield package. Methods are stateless and free from side-effects. It was designed to be chainable so error reporting is omitted: you need to make sure position is in the range of [0, 63]

For usage see test file.

Documentation

Overview

Package bitfield64 is a simple, quick stack-based bit-field manipulator package of 64 bits (or less) in length. If you need more bits you either need to create an array of bitfield64-s (and stay on the stack) or need to switch to the heap-based bitfield package. Methods are stateless and free from side-effects. It was designed to be chainable. Range for position must be [0, 63]. position outside this range will get modulo treatment, so 64 will point to the 0th element, -1 will address the last element (i.e. 63rd), -2 the one before (i.e. 62nd), etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitField64

type BitField64 uint64

BitField64 type utilizing the power of 64bit CPUs. It lives on the stack

func New

func New() BitField64

New returns a zeroed (all false) bit-field that can store size elements

func (BitField64) And

func (bf64 BitField64) And(bfo BitField64) BitField64

And returns the binary AND of the two bitfields

func (BitField64) Clear

func (bf64 BitField64) Clear(pos int) BitField64

Clear clears the bit at position pos

func (BitField64) ClearAll

func (bf64 BitField64) ClearAll() BitField64

ClearAll returns a bitfield where all 64 bits are set

func (BitField64) Get

func (bf64 BitField64) Get(pos int) bool

Get returns true if bit at position pos is set, false otherwise

func (BitField64) Not

func (bf64 BitField64) Not() BitField64

Not returns the bitfield with each bit inverted: 0 becomes 1, 1 becomes 0

func (BitField64) OnesCount

func (bf64 BitField64) OnesCount() int

OnesCount returns the number of bits set

func (BitField64) Or

func (bf64 BitField64) Or(bfo BitField64) BitField64

Or returns the binary OR of the two bitfields

func (BitField64) Set

func (bf64 BitField64) Set(pos int) BitField64

Set sets the bit at position pos

func (BitField64) SetAll

func (bf64 BitField64) SetAll() BitField64

SetAll returns a bitfield where all 64 bits are set

func (BitField64) Xor

func (bf64 BitField64) Xor(bfo BitField64) BitField64

Xor returns the binary XOR of the two bitfields

Jump to

Keyboard shortcuts

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