bitmask

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has[B Bit, M Bitmask[B]](a, b M) bool

Has returns true if (a & b) > 0.

func Set

func Set[B Bit, M Bitmask[B]](a, b M) M

Set returns a new mask of a | b.

func String

func String[B Bit, M Bitmask[B]](a M) string

String returns the stringified version of the mask.

func Unset

func Unset[B Bit, M Bitmask[B]](a, b M) M

Unset returns a new mask of a &^ b.

Types

type Bit

type Bit interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64

	// StringValue returns the string-ified value for the bit.
	StringValue() string
}

Bit is a type constraint that includes all unsigned integers.

type Bitmask

type Bitmask[T Bit] interface {
	Bit

	// MaxValue returns the maximum, valid bit that may be set in the mask.
	MaxValue() T
}

Bitmask is a type constraint that can be used as a bitmask.

Jump to

Keyboard shortcuts

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