dispatch/Godeps/_workspace/src/github.com/willf/bitset
khlieng 3365832ce3 Add message logging and search server side 2015-04-29 23:54:44 +02:00
..
.gitignore Add message logging and search server side 2015-04-29 23:54:44 +02:00
CHANGELOG Add message logging and search server side 2015-04-29 23:54:44 +02:00
LICENSE.txt Add message logging and search server side 2015-04-29 23:54:44 +02:00
README.md Add message logging and search server side 2015-04-29 23:54:44 +02:00
bitset.go Add message logging and search server side 2015-04-29 23:54:44 +02:00
bitset_test.go Add message logging and search server side 2015-04-29 23:54:44 +02:00
popcnt.go Add message logging and search server side 2015-04-29 23:54:44 +02:00
popcnt_amd64.s Add message logging and search server side 2015-04-29 23:54:44 +02:00
popcnt_asm.go Add message logging and search server side 2015-04-29 23:54:44 +02:00
popcnt_generic.go Add message logging and search server side 2015-04-29 23:54:44 +02:00

README.md

Package bitset implements bitsets, a mapping between non-negative integers and boolean values. It should be more efficient than map[uint] bool.

It provides methods for setting, clearing, flipping, and testing individual integers.

But 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 postive bits.

BitSets 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.

Many of the methods, including Set, Clear, and Flip, return a BitSet pointer, which allows for chaining.

Example use:

import "bitset"
var b BitSet
b.Set(10).Set(11)
if b.Test(1000) {
	b.Clear(1000)
}
for i,e := v.NextSet(0); e; i,e = v.NextSet(i + 1) {
   frmt.Println("The following bit is set:",i);
}
if B.Intersection(bitset.New(100).Set(10)).Count() > 1 {
	fmt.Println("Intersection works.")
}

As an alternative to BitSets, one should check out the 'big' package, which provides a (less set-theoretical) view of bitsets.

Discussions golang-nuts Google Group:

Godoc documentation is at: https://godoc.org/github.com/willf/bitset