bitslice

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package bitslice implements a simple slice-of-bits using a []byte slice for storage. used for efficient storage of binary data, such as projection connectivity patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitIdx

func BitIdx(idx int) (byte int, bit uint32)

BitIdx returns the byte, bit index of given bit index

Types

type Slice

type Slice []byte

bitslice.Slice is the slice of []byte that holds the bits. first byte maintains the number of bits used in the last byte (0-7). when 0 then prior byte is all full and a new one must be added for append.

func Make

func Make(ln, cp int) Slice

Make makes a new bitslice of given length and capacity (optional, pass 0 for default) *bits* (rounds up 1 for both). also reserves first byte for extra bits value

func (*Slice) Append

func (bs *Slice) Append(val bool) Slice

Append adds a bit to the slice and returns possibly new slice, possibly old slice..

func (*Slice) Cap

func (bs *Slice) Cap() int

Cap returns the capacity of the slice in bits -- always modulo 8

func (*Slice) Clone

func (bs *Slice) Clone() Slice

Clone creates a new copy of this bitslice with separate memory

func (*Slice) Index

func (bs *Slice) Index(idx int) bool

Index returns bit value at given bit index

func (*Slice) Len

func (bs *Slice) Len() int

Len returns the length of the slice in bits

func (*Slice) Set

func (bs *Slice) Set(idx int, val bool)

Set sets value of given bit index -- no extra range checking is performed -- will panic if out of range

func (*Slice) SetAll

func (bs *Slice) SetAll(val bool)

SetAll sets all values to either on or off -- much faster than setting individual bits

func (*Slice) SetLen

func (bs *Slice) SetLen(ln int)

SetLen sets the length of the slice, copying values if a new allocation is required

func (*Slice) String

func (bs *Slice) String() string

String satisfies the fmt.Stringer interface

func (*Slice) ToBools

func (bs *Slice) ToBools() []bool

ToBools converts to a []bool slice

Jump to

Keyboard shortcuts

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