binary

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package binary ... thanks to https://github.com/skip2/go-qrcode/blob/master/bitset/bitset.go I cannot do any better for now, so I just learn and write it again~

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binary

type Binary struct {
	// contains filtered or unexported fields
}

Binary struct contains bits stream and methods to be called from outside exsample: b.Len() b.Subset(start, end) b.At(pos)

func New

func New(booleans ...bool) *Binary

New ...

func NewFromBinaryString

func NewFromBinaryString(s string) (*Binary, error)

NewFromBinaryString ... generate Bitset from binary string auto get length

func (*Binary) Append

func (b *Binary) Append(other *Binary)

Append other bitset link another Bitset to after the b

func (*Binary) AppendBools

func (b *Binary) AppendBools(booleans ...bool)

AppendBools append multi bool after the bit stream of b

func (*Binary) AppendByte

func (b *Binary) AppendByte(byt byte, numBits int) error

AppendByte ... specified num bits to append

func (*Binary) AppendBytes

func (b *Binary) AppendBytes(byts ...byte)

AppendBytes ...

func (*Binary) AppendNumBools

func (b *Binary) AppendNumBools(num int, boolean bool)

AppendNumBools appends num bits of value value.

func (*Binary) AppendUint32

func (b *Binary) AppendUint32(value uint32, numBits int)

AppendUint32 other bitset link another Bitset to after the b

func (*Binary) At

func (b *Binary) At(pos int) bool

At .get boolean value from

func (*Binary) Bytes

func (b *Binary) Bytes() []byte

Bytes ...

func (*Binary) Copy

func (b *Binary) Copy() *Binary

Copy ...

func (*Binary) EqualTo

func (b *Binary) EqualTo(other *Binary) bool

EqualTo ...

func (*Binary) Len

func (b *Binary) Len() int

Len ...

func (*Binary) String

func (b *Binary) String() string

String for printing

func (*Binary) Subset

func (b *Binary) Subset(start, end int) (*Binary, error)

Subset do the same work like slice[start:end]

func (*Binary) VisitAll

func (b *Binary) VisitAll(f IterFunc)

VisitAll loop the b.bits stream and send value into IterFunc

type IterFunc

type IterFunc func(pos int, v bool)

IterFunc used by func b.VisitAll ...

Jump to

Keyboard shortcuts

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