bitset

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

nolint:mnd

nolint:mnd

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitset32

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

func New32

func New32(n uint32) *Bitset32

Make a new bitset with a starting capacity of n bits. The bitset expands automatically.

func NewFromBytes32

func NewFromBytes32(data []byte) (*Bitset32, error)

NewFromBytes32 deserializes a byte slice into a Bitset32.

func (*Bitset32) All

func (b *Bitset32) All() bool

Returns true if all bits in the bitset are set.

func (*Bitset32) Any

func (b *Bitset32) Any() bool

Return true if any bit in the bitset is set.

func (*Bitset32) Clear

func (b *Bitset32) Clear(i uint32)

Set bit i to 0.

func (*Bitset32) Clone

func (b *Bitset32) Clone() *Bitset32

Clone the bitset.

func (*Bitset32) Complement

func (b *Bitset32) Complement() (result *Bitset32)

Return the (local) complement of a bitset (up to n bits).

func (*Bitset32) Copy

func (b *Bitset32) Copy(c *Bitset32) (n uint32)

Copy the bitset into another bitset, returning the size of the destination bitset.

func (*Bitset32) Count

func (b *Bitset32) Count() uint32

Get the number of set bits in the bitset.

func (*Bitset32) Difference

func (b *Bitset32) Difference(ob *Bitset32) (result *Bitset32)

Bitset &^ (and or); difference between receiver and another set.

func (*Bitset32) Equal

func (b *Bitset32) Equal(c *Bitset32) bool

Test if two bitsets are equal. Returns true if both bitsets are the same size and all the same bits are set in both bitsets.

func (*Bitset32) Flip

func (b *Bitset32) Flip(i uint32)

Flip bit i.

func (*Bitset32) Intersection

func (b *Bitset32) Intersection(ob *Bitset32) (result *Bitset32)

Bitset & (and); intersection of receiver and another set.

func (*Bitset32) Len

func (b *Bitset32) Len() uint32

Returns the current size of the bitset.

func (*Bitset32) None

func (b *Bitset32) None() bool

Returns true if no bit in the bitset is set.

func (*Bitset32) Reset

func (b *Bitset32) Reset()

Clear all bits in the bitset.

func (*Bitset32) Set

func (b *Bitset32) Set(i uint32)

Set bit i to 1.

func (*Bitset32) String

func (b *Bitset32) String() string

Get a string representation of the words in the bitset.

func (*Bitset32) SymmetricDifference

func (b *Bitset32) SymmetricDifference(ob *Bitset32) (result *Bitset32)

Bitset ^ (xor); symmetric difference of receiver and another set.

func (*Bitset32) Test

func (b *Bitset32) Test(i uint32) bool

Test whether bit i is set.

func (*Bitset32) ToBytes

func (b *Bitset32) ToBytes() ([]byte, error)

ToBytes serializes the Bitset32 to a byte slice.

func (*Bitset32) Union

func (b *Bitset32) Union(ob *Bitset32) (result *Bitset32)

Bitset | (or); union of receiver and another set.

type Bitset64

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

func New64

func New64(n uint64) *Bitset64

Make a new bitset with a starting capacity of n bits. The bitset expands automatically.

func NewFromBytes64

func NewFromBytes64(data []byte) (*Bitset64, error)

NewFromBytes64 deserializes a byte slice into a Bitset64.

func (*Bitset64) All

func (b *Bitset64) All() bool

Returns true if all bits in the bitset are set.

func (*Bitset64) Any

func (b *Bitset64) Any() bool

Return true if any bit in the bitset is set.

func (*Bitset64) CleanLastWord

func (b *Bitset64) CleanLastWord()

CleanLastWord clean last word by setting unused bits to 0.

func (*Bitset64) Clear

func (b *Bitset64) Clear(i uint64)

Set bit i to 0.

func (*Bitset64) Clone

func (b *Bitset64) Clone() *Bitset64

Clone the bitset.

func (*Bitset64) Copy

func (b *Bitset64) Copy(c *Bitset64) (n uint64)

Copy the bitset into another bitset, returning the size of the destination bitset.

func (*Bitset64) Count

func (b *Bitset64) Count() uint64

Get the number of set bits in the bitset.

func (*Bitset64) Difference

func (b *Bitset64) Difference(ob *Bitset64) (result *Bitset64)

Bitset &^ (and or); difference between receiver and another set.

func (*Bitset64) Equal

func (b *Bitset64) Equal(c *Bitset64) bool

Test if two bitsets are equal. Returns true if both bitsets are the same size and all the same bits are set in both bitsets.

func (*Bitset64) Flip

func (b *Bitset64) Flip(i uint64)

Flip bit i.

func (*Bitset64) Intersection

func (b *Bitset64) Intersection(ob *Bitset64) (result *Bitset64)

Bitset & (and); intersection of receiver and another set.

func (*Bitset64) IsEven

func (b *Bitset64) IsEven() bool

IsEven return true if the bitset's length is a multiple of the word size.

func (*Bitset64) Len

func (b *Bitset64) Len() uint64

Returns the current size of the bitset.

func (*Bitset64) None

func (b *Bitset64) None() bool

Returns true if no bit in the bitset is set.

func (*Bitset64) Reset

func (b *Bitset64) Reset()

Clear all bits in the bitset.

func (*Bitset64) Set

func (b *Bitset64) Set(i uint64)

Set bit i to 1.

func (*Bitset64) String

func (b *Bitset64) String() string

Get a string representation of the words in the bitset.

func (*Bitset64) SymmetricDifference

func (b *Bitset64) SymmetricDifference(ob *Bitset64) (result *Bitset64)

Bitset ^ (xor); symmetric difference of receiver and another set.

func (*Bitset64) Test

func (b *Bitset64) Test(i uint64) bool

Test whether bit i is set.

func (*Bitset64) ToBytes

func (b *Bitset64) ToBytes() ([]byte, error)

ToBytes serializes the Bitset64 to a byte slice.

func (*Bitset64) Union

func (b *Bitset64) Union(ob *Bitset64) (result *Bitset64)

Bitset | (or); union of receiver and another set.

Jump to

Keyboard shortcuts

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