Skip to content

Commit e1dbb9f

Browse files
committed
Add tutorial
1 parent bca2544 commit e1dbb9f

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"math"
77
)
88

9-
// Create, combine, compare and print bit arrays.
9+
// Create, combine, compare and print bit sets.
1010
func Example_basics() {
1111
// Add all elements in the range [0, 100) to the empty set.
1212
A := new(bit.Set).AddRange(0, 100) // {0..99}
@@ -30,7 +30,7 @@ func Example_basics() {
3030

3131
// Create the set of all primes less than n in O(n log log n) time.
3232
// Try the code with n equal to a few hundred millions and be pleasantly surprised.
33-
func Example_eratosthenes() {
33+
func Example_primes() {
3434
// Sieve of Eratosthenes
3535
const n = 50
3636
sieve := bit.New().AddRange(2, n)

set.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@
1111
//
1212
// Bit set
1313
//
14-
// A bit array, or bit set, is an efficient set data structure
14+
// A bit set, or bit array, is an efficient set data structure
1515
// that consists of an array of 64-bit words. Because it uses
1616
// bit-level parallelism, limits memory access, and efficiently uses
1717
// the data cache, a bit set often outperforms other data structures.
1818
//
19+
// Tutorial
20+
//
21+
// The Basics example shows how to create, combine, compare and
22+
// print bit sets.
23+
//
24+
// Primes contains a short and simple, but still efficient,
25+
// implementation of a prime number sieve.
26+
//
27+
// Union is a more advanced example demonstrating how to build
28+
// an efficient variadic Union function using the SetOr method.
29+
//
1930
package bit
2031

2132
import (

0 commit comments

Comments
 (0)