bitmap

package
v0.0.0-...-d9d0c30 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitMap

type BitMap struct {
	// contains filtered or unexported fields
}

位图

func NewBitMap

func NewBitMap(max uint32) *BitMap

初始化一个BitMap 一个byte有8位,可代表8个数字,取余后加1为存放最大数所需的容量

func NewEmptyBitMap

func NewEmptyBitMap() *BitMap

初始化一个空的BitMap,以备反序列化填充

func (*BitMap) Add

func (b *BitMap) Add(num uint) *BitMap

添加一个数字到位图 计算添加数字在数组中的索引index,一个索引可以存放8个数字 计算存放到索引下的第几个位置,一共0-7个位置 原索引下的内容与1左移到指定位置后做或运算

func (*BitMap) AddFull

func (b *BitMap) AddFull() *BitMap

全位设置 1

func (*BitMap) IsEmpty

func (b *BitMap) IsEmpty() bool

是不是全位空

func (*BitMap) IsExist

func (b *BitMap) IsExist(num uint) bool

判断一个数字是否在位图 找到数字所在的位置,然后做与运算

func (*BitMap) IsFull

func (b *BitMap) IsFull() bool

是不是全位设置

func (*BitMap) Len

func (b *BitMap) Len() int

bytes length

func (*BitMap) Max

func (b *BitMap) Max() uint32

位图的最大数字

func (*BitMap) Remove

func (b *BitMap) Remove(num uint) *BitMap

删除一个数字在位图 找到数字所在的位置取反,然后与索引下的数字做与运算

func (*BitMap) RemoveAll

func (b *BitMap) RemoveAll() *BitMap

全位设置 0

func (*BitMap) Serialize

func (b *BitMap) Serialize() []byte

序列化

func (*BitMap) String

func (b *BitMap) String() string

func (*BitMap) UnSerialize

func (b *BitMap) UnSerialize(in []byte) error

反序列化

Jump to

Keyboard shortcuts

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