bitset

package
v0.0.0-...-884cce2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 1 Imported by: 0

README

This package implements some features similar to C++'s bitset.

Why not make bitset a type?

Often you might need to do:

result := (bitset1 | bitset2) & bitset3

If bitset was a type, you'd have to cast quite a bit to achieve this:

result := Bitset(uint64(bitset1) | uint64(bitset2)) & uint64(bitset3))

It would be tempting then to make methods And and Or, etc but this also hurts readability.

result := (bitset1.Or(bitset2)).And(bitset3)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear(bitset *uint64, index int)

Clear sets the bit at index to 0.

func Count

func Count(bitset uint64) int

Count returns the amount of set bits in the bitset.

func EachSetBit

func EachSetBit(bitset uint64, callback func(i int))

EachSetBit calls the callback for each set bit in the bitset.

func IsSet

func IsSet(bitset uint64, index int) bool

IsSet returns true if the bit at index is set.

func Set

func Set(bitset *uint64, index int)

Set sets the bit at index to 1.

Types

This section is empty.

Jump to

Keyboard shortcuts

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