bitset

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet

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

BitSet is an implementation of a resizable bit set.

func New

func New(capacity int) *BitSet

New creates a BitSet with the given bit capacity.

All methods will panic if the specified bit index is out of range.

func (*BitSet) And

func (b *BitSet) And(other *BitSet)

And performs the bitwise AND operation with another BitSet.

If the other BitSet is larger than the current one, this operation will panic. If it is smaller, only the existing bits from the other BitSet will be used for the operation.

func (*BitSet) Capacity

func (b *BitSet) Capacity() int

Capacity returns the current capacity.

func (*BitSet) Clear

func (b *BitSet) Clear()

Clear clears all the bits in the BitSet

func (*BitSet) Clone

func (b *BitSet) Clone() *BitSet

Clone clones the BitSet, returning a new instance with the same bits set.

func (*BitSet) Get

func (b *BitSet) Get(bit int) bool

Get gets the value of a bit.

func (*BitSet) Grow

func (b *BitSet) Grow(capacity int)

Grow grows the BitSet to a greater capacity.

Panics if the capacity is not greater than the current capacity.

func (*BitSet) IsEmpty

func (b *BitSet) IsEmpty() bool

IsEmpty returns whether every bit's value is 0.

func (*BitSet) Not

func (b *BitSet) Not()

Not toggles all the bits in the BitSet

func (*BitSet) Or

func (b *BitSet) Or(other *BitSet)

Or performs the bitwise OR operation with another BitSet.

If the other BitSet is larger than the current one, this operation will panic. If it is smaller, only the existing bits from the other BitSet will be used for the operation.

func (*BitSet) Set

func (b *BitSet) Set(bit int)

Set sets the value of a bit to 1.

func (*BitSet) Shrink

func (b *BitSet) Shrink(capacity int)

Shrink shrinks the BitSet to a smaller capacity.

Panics if the capacity is not smaller than the current capacity.

func (*BitSet) String

func (b *BitSet) String() string

String converts the internal bits to a binary string representation.

func (*BitSet) Toggle

func (b *BitSet) Toggle(bit int)

Toggle toggles the value of a bit.

func (*BitSet) Unset

func (b *BitSet) Unset(bit int)

Unset sets the value of a bit to 0.

func (*BitSet) Xor

func (b *BitSet) Xor(other *BitSet)

Xor performs the bitwise XOR operation with another BitSet.

If the other BitSet is larger than the current one, this operation will panic. If it is smaller, only the existing bits from the other BitSet will be used for the operation.

Jump to

Keyboard shortcuts

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