Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thetardigrade/golang-infinitebitmask
This Go package allows for the creation of bitmasks of theoretically infinite size.
https://github.com/thetardigrade/golang-infinitebitmask
big-integer bigint bitmask bitmask-library bitmasking go golang
Last synced: 8 days ago
JSON representation
This Go package allows for the creation of bitmasks of theoretically infinite size.
- Host: GitHub
- URL: https://github.com/thetardigrade/golang-infinitebitmask
- Owner: theTardigrade
- Created: 2022-02-06T23:23:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-11T10:53:36.000Z (almost 3 years ago)
- Last Synced: 2024-11-08T11:13:39.770Z (2 months ago)
- Topics: big-integer, bigint, bitmask, bitmask-library, bitmasking, go, golang
- Language: Go
- Homepage:
- Size: 96.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# golang-infiniteBitmask
This Go package allows for the creation of bitmasks of theoretically infinite size.
## Example
```golang
package mainimport (
"fmt"bitmask "github.com/theTardigrade/golang-infiniteBitmask"
)func main() {
g := bitmask.NewGenerator()start := g.ValueFromName("start")
stop := g.ValueFromName("stop")
pause := g.ValueFromName("pause")
reset := g.ValueFromName("reset")fmt.Println("start:", start.String()) // 1
fmt.Println("stop:", stop.String()) // 10
fmt.Println("pause:", pause.String()) // 100
fmt.Println("reset:", reset.String()) // 1000startAndReset := g.ValueFromNames("start", "reset")
fmt.Println("start and reset:", startAndReset.String()) // 1001
if startAndReset.Number().Uint64() == start.Number().Uint64()|reset.Number().Uint64() {
fmt.Println("match [1]")
}startAndReset2 := start.Clone()
startAndReset2.Combine(reset)if startAndReset.Equal(startAndReset2) {
fmt.Println("match [2]")
}if startAndReset.String() == startAndReset2.String() {
fmt.Println("match [3]")
}empty := start.Clone()
empty.Clear()if empty.Number().Uint64() == 0 {
fmt.Println("match [4]")
}fmt.Println(g.String()) // ["start","stop","pause","reset"]
if g2 := bitmask.NewGeneratorFromString(g.String()); g.String() == g2.String() {
fmt.Println("match [5]")
}
}
```