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) Copy() *Bitfield
- func (b *Bitfield) Count() uint32
- 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) 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) 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.