https://github.com/josestg/u8bitset
https://github.com/josestg/u8bitset
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/josestg/u8bitset
- Owner: josestg
- License: mit
- Created: 2023-08-21T15:54:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-21T08:39:55.000Z (over 1 year ago)
- Last Synced: 2025-01-31T06:47:21.542Z (3 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# u8bitset
A simple implementation of BitSet for `uint8` type in Go.
## Usage
```go
package mainimport (
"fmt"
"github.com/josestg/u8bitset"
)func main() {
set := u8bitset.New()
str := "Hello, World!"
for _, c := range str {
set.Add(uint8(c))
}other := "World!"
otherSet := u8bitset.New()
for _, c := range other {
otherSet.Add(uint8(c))
}fmt.Println(set.Has(uint8('H'))) // true
fmt.Println(set.Has(uint8('h'))) // false
fmt.Println(set.Cardinal()) // 10intersection := set.Intersection(otherSet).Values()
fmt.Printf("Intersection: %s\n", intersection) // Intersection: !Wdorl}
```