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 ¶
- func BitIdx(idx int) (byte int, bit uint32)
- type Slice
- func (bs *Slice) Append(val bool) Slice
- func (bs *Slice) Cap() int
- func (bs *Slice) Clone() Slice
- func (bs *Slice) Delete(start, n int) Slice
- func (bs *Slice) Index(idx int) bool
- func (bs *Slice) Insert(start, n int) Slice
- func (bs *Slice) Len() int
- func (bs *Slice) Set(idx int, val bool)
- func (bs *Slice) SetAll(val bool)
- func (bs *Slice) SetLen(ln int)
- func (bs *Slice) String() string
- func (bs *Slice) SubSlice(start, end int) Slice
- func (bs *Slice) ToBools() []bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
Append adds a bit to the slice and returns possibly new slice, possibly old slice..
func (*Slice) Delete ¶ added in v1.0.17
Delete returns a new bit slice with N elements removed starting at given index. This must be a copy given the nature of the 8-bit aliasing.
func (*Slice) Insert ¶ added in v1.0.17
Insert returns a new bit slice with N false elements inserted starting at given index. This must be a copy given the nature of the 8-bit aliasing.
func (*Slice) Set ¶
Set sets value of given bit index -- no extra range checking is performed -- will panic if out of range
func (*Slice) SetAll ¶
SetAll sets all values to either on or off -- much faster than setting individual bits
func (*Slice) SetLen ¶
SetLen sets the length of the slice, copying values if a new allocation is required