Documentation ¶
Overview ¶
Package bitfield provides support for manipulating bits in a []byte.
Index ¶
- func NumBytes(length uint32) int
- type Bitfield
- func (b *Bitfield) All() bool
- func (b *Bitfield) And(b2 *Bitfield)
- func (b *Bitfield) Bytes() []byte
- func (b *Bitfield) Clear(i uint32)
- func (b *Bitfield) ClearAll()
- func (b *Bitfield) Copy() *Bitfield
- func (b *Bitfield) Count() uint32
- func (b *Bitfield) FirstClear(start uint32) (uint32, bool)
- func (b *Bitfield) FirstSet(start uint32) (uint32, bool)
- func (b *Bitfield) Hex() string
- func (b *Bitfield) Len() uint32
- func (b *Bitfield) Or(b2 *Bitfield)
- func (b *Bitfield) Set(i uint32)
- func (b *Bitfield) SetTo(i uint32, value bool)
- func (b *Bitfield) Test(i uint32) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bitfield ¶
type Bitfield struct {
// contains filtered or unexported fields
}
Bitfield is described in BEP 3.
func NewBytes ¶
NewBytes returns a new Bitfield from bytes. Bytes in b are not copied. Unused bits in last byte are cleared. Panics if b is not big enough to hold "length" bits.
func (*Bitfield) Bytes ¶
Bytes returns bytes in b. If you modify the returned slice the bits in b are modified too.
func (*Bitfield) FirstClear ¶
FirstClear returns the index of the first bit that is not set starting from start.
func (*Bitfield) FirstSet ¶
FirstSet returns the index of the first bit that is set starting from start.
func (*Bitfield) Hex ¶
Hex returns bytes as string. If not all the bits in last byte are used, they encode as not set.
Click to show internal directories.
Click to hide internal directories.