A Go library implementing memory-efficient bitsets for mapping non-negative integers to boolean values.
Bitset is a Go library that implements bitsets, a data structure for mapping non-negative integers to boolean values. It provides an efficient alternative to using map[uint]bool, with optimized memory usage and fast set operations like union, intersection, and difference. The library is designed for performance and is used in production by systems like Beego, CubeFS, and Amazon EKS Distro.
Go developers working on systems that require efficient set operations on integer ranges, such as database indexing, network routing, or data filtering applications.
Developers choose Bitset for its superior performance over standard maps, comprehensive set operation support, and production-ready reliability. Its memory efficiency and serialization capabilities make it ideal for high-performance applications.
Go package implementing bitsets
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses at least N/8 bytes for N bits, significantly reducing memory compared to map[uint]bool, as documented in the README.
Supports intersection, union, difference, and other operations with chaining methods, optimized for performance in systems like database indexing.
Widely used in production by systems such as Beego and Amazon EKS Distro, indicating proven stability and robustness.
Provides safe serialization to byte streams with WriteTo and ReadFrom methods, enabling easy storage and network transmission.
Unsynchronized by default; requires external mechanisms like sync.Mutex or channels for concurrent access, adding complexity.
Bitsets never shrink automatically, necessitating explicit Shrink or Compact calls, which can lead to memory leaks if overlooked.
Only supports non-negative integers, making it unsuitable for applications involving negative numbers or other data types.