{"id":37099116,"url":"https://github.com/paralin/go-blooms-bitset","last_synced_at":"2026-01-14T12:02:48.252Z","repository":{"id":57649856,"uuid":"378766015","full_name":"paralin/go-blooms-bitset","owner":"paralin","description":"Go package implementing bitsets","archived":false,"fork":true,"pushed_at":"2022-03-21T11:33:42.000Z","size":372,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-05T22:36:22.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"bits-and-blooms/bitset","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paralin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":null,"open_collective":null,"ko_fi":null,"custom":"https://donate.mcc.org/"}},"created_at":"2021-06-21T00:30:51.000Z","updated_at":"2022-01-10T18:40:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/paralin/go-blooms-bitset","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/paralin/go-blooms-bitset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgo-blooms-bitset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgo-blooms-bitset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgo-blooms-bitset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgo-blooms-bitset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paralin","download_url":"https://codeload.github.com/paralin/go-blooms-bitset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paralin%2Fgo-blooms-bitset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T12:02:47.546Z","updated_at":"2026-01-14T12:02:48.247Z","avatar_url":"https://github.com/paralin.png","language":"Go","funding_links":["https://donate.mcc.org/"],"categories":[],"sub_categories":[],"readme":"# bitset\n\n*Go language library to map between non-negative integers and boolean values*\n\n[![Test](https://github.com/bits-and-blooms/bitset/workflows/Test/badge.svg)](https://github.com/willf/bitset/actions?query=workflow%3ATest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/willf/bitset)](https://goreportcard.com/report/github.com/willf/bitset)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/bits-and-blooms/bitset?tab=doc)](https://pkg.go.dev/github.com/bits-and-blooms/bitset?tab=doc)\n\n\n## Description\n\nPackage bitset implements bitsets, a mapping between non-negative integers and boolean values.\nIt should be more efficient than map[uint] bool.\n\nIt provides methods for setting, clearing, flipping, and testing individual integers.\n\nBut it also provides set intersection, union, difference, complement, and symmetric operations, as well as tests to check whether any, all, or no bits are set, and querying a bitset's current length and number of positive bits.\n\nBitSets are expanded to the size of the largest set bit; the memory allocation is approximately Max bits, where Max is the largest set bit. BitSets are never shrunk. On creation, a hint can be given for the number of bits that will be used.\n\nMany of the methods, including Set, Clear, and Flip, return a BitSet pointer, which allows for chaining.\n\n### Example use:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math/rand\"\n\n\t\"github.com/bits-and-blooms/bitset\"\n)\n\nfunc main() {\n\tfmt.Printf(\"Hello from BitSet!\\n\")\n\tvar b bitset.BitSet\n\t// play some Go Fish\n\tfor i := 0; i \u003c 100; i++ {\n\t\tcard1 := uint(rand.Intn(52))\n\t\tcard2 := uint(rand.Intn(52))\n\t\tb.Set(card1)\n\t\tif b.Test(card2) {\n\t\t\tfmt.Println(\"Go Fish!\")\n\t\t}\n\t\tb.Clear(card1)\n\t}\n\n\t// Chaining\n\tb.Set(10).Set(11)\n\n\tfor i, e := b.NextSet(0); e; i, e = b.NextSet(i + 1) {\n\t\tfmt.Println(\"The following bit is set:\", i)\n\t}\n\tif b.Intersection(bitset.New(100).Set(10)).Count() == 1 {\n\t\tfmt.Println(\"Intersection works.\")\n\t} else {\n\t\tfmt.Println(\"Intersection doesn't work???\")\n\t}\n}\n```\n\nAs an alternative to BitSets, one should check out the 'big' package, which provides a (less set-theoretical) view of bitsets.\n\nPackage documentation is at: https://pkg.go.dev/github.com/bits-and-blooms/bitset?tab=doc\n\n## Memory Usage\n\nThe memory usage of a bitset using N bits is at least N/8 bytes. The number of bits in a bitset is at least as large as one plus the greatest bit index you have accessed. Thus it is possible to run out of memory while using a bitset. If you have lots of bits, you might prefer compressed bitsets, like the [Roaring bitmaps](http://roaringbitmap.org) and its [Go implementation](https://github.com/RoaringBitmap/roaring).\n\n## Implementation Note\n\nGo 1.9 introduced a native `math/bits` library. We provide backward compatibility to Go 1.7, which might be removed.\n\nIt is possible that a later version will match the `math/bits` return signature for counts (which is `int`, rather than our library's `unit64`). If so, the version will be bumped.\n\n## Installation\n\n```bash\ngo get github.com/bits-and-blooms/bitset\n```\n\n## Contributing\n\nIf you wish to contribute to this project, please branch and issue a pull request against master (\"[GitHub Flow](https://guides.github.com/introduction/flow/)\")\n\n## Running all tests\n\nBefore committing the code, please check if it passes tests, has adequate coverage, etc.\n```bash\ngo test\ngo test -cover\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparalin%2Fgo-blooms-bitset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparalin%2Fgo-blooms-bitset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparalin%2Fgo-blooms-bitset/lists"}