bitmap

package
v0.0.0-...-c8d95c1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bitmap implements bitmaps that maintain their length in bytes and behave compatibly with the bitfields used in the BitTorrent protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap []uint8

func New

func New(length int) Bitmap

func (Bitmap) All

func (b Bitmap) All(n int) bool

All returns true if all bits from 0 up to n - 1 are set.

func (Bitmap) Copy

func (b Bitmap) Copy() Bitmap

Copy copies a bitmap.

func (Bitmap) Count

func (b Bitmap) Count() int

Count returns the number of bits set.

func (Bitmap) Empty

func (b Bitmap) Empty() bool

Empty returns true if no bits are set.

func (Bitmap) EqualValue

func (b1 Bitmap) EqualValue(b2 Bitmap) bool

EqualValue returns true if two bitmaps have the same bits set (ignoring any trailing zeroes).

func (*Bitmap) Extend

func (b *Bitmap) Extend(i int)

Extend sets the length of the bitmap to at least the smallest multiple of 8 that is strictly larger than i.

func (Bitmap) Get

func (b Bitmap) Get(i int) bool

Get returns true if the ith bit is set.

func (Bitmap) Len

func (b Bitmap) Len() int

Len returns the index of the highest bit set, plus one.

func (Bitmap) Range

func (b Bitmap) Range(f func(index int) bool)

Range applies a given function on all set values in a bitmap in increasing order. The iteration is interrupted when the function returns false.

func (*Bitmap) Reset

func (b *Bitmap) Reset(i int)

Reset resets the ith bit of the bitmap.

func (*Bitmap) Set

func (b *Bitmap) Set(i int)

Set sets the ith bit of the bitmap, extending it if necessery.

func (*Bitmap) SetMultiple

func (b *Bitmap) SetMultiple(n int)

Sets all bits from 0 up to n - 1.

func (Bitmap) String

func (b Bitmap) String() string

Jump to

Keyboard shortcuts

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