bitmask

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 1 Imported by: 0

README

bitmask

Simple utilities for working with bitmasks. Built with generics so any form of unsigned or signed integer is supported.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[T Bit](sum, bit T) T

Add adds a given bit to the sum.

func Has

func Has[T Bit](sum, bit T) bool

Has checks whether a given bit exists in sum.

func Remove

func Remove[T Bit](sum, bit T) T

Remove removes bit from the sum.

func Toggle added in v0.0.13

func Toggle[T Bit](sum, bit T) T

Toggle will either add or remove bit from sum depending on whether it currently exists in the bitmask.

Types

type Bit

type Bit interface {
	constraints.Integer
}

Bit is a generic type that exports the supported values that can be used in the bitmask. Any form of integer is currently supported.

Jump to

Keyboard shortcuts

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