bitmask

package module
v0.0.0-...-64391c2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: ISC Imports: 0 Imported by: 0

README

bitmask

-- import "vimagination.zapto.org/bitmask"

Package bitmask implements a simple bitmask type.

Usage

type BitMask
type BitMask []byte

BitMask is the main type. It is completely safe to cast from an existing byte slice or to create a BitMask with make.

func New
func New(bits int) BitMask

New creates a new BitMask with enough storage to hold at least the required number of bits.

func (BitMask) Get
func (b BitMask) Get(bit int) bool

Get will retrieve the bool stored at given bit position.

func (BitMask) Set
func (b BitMask) Set(bit int, d bool)

Set will set the given bool at the given position.

func (BitMask) SetIfNot
func (b BitMask) SetIfNot(bit int, d bool) bool

SetIfNot will set the given bool at the given position and return true if the value has changed.

Documentation

Overview

Package bitmask implements a simple bitmask type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitMask

type BitMask []byte

BitMask is the main type. It is completely safe to cast from an existing byte slice or to create a BitMask with make.

func New

func New(bits int) BitMask

New creates a new BitMask with enough storage to hold at least the required number of bits.

func (BitMask) Get

func (b BitMask) Get(bit int) bool

Get will retrieve the bool stored at given bit position.

func (BitMask) Set

func (b BitMask) Set(bit int, d bool)

Set will set the given bool at the given position.

func (BitMask) SetIfNot

func (b BitMask) SetIfNot(bit int, d bool) bool

SetIfNot will set the given bool at the given position and return true if the value has changed.

Jump to

Keyboard shortcuts

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