Skip to content

Commit 076b22d

Browse files
authored
Merge pull request #7 from yourbasic/tip
Tip
2 parents 8fa2857 + 32a092b commit 076b22d

File tree

5 files changed

+601
-19
lines changed

5 files changed

+601
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Your basic bit
1+
# Your basic bit [![GoDoc](https://godoc.org/github.com/yourbasic/bit?status.svg)][godoc-bit]
22

33
### Golang set data structure with bonus bit-twiddling functions
44

bench_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@ package bit
22

33
import "testing"
44

5-
func BenchmarkLeadingZeros(b *testing.B) {
6-
for i := 0; i < b.N; i++ {
7-
LeadingZeros(0xcafecafecafecafe)
8-
}
9-
}
10-
11-
func BenchmarkTrailingZeros(b *testing.B) {
12-
for i := 0; i < b.N; i++ {
13-
TrailingZeros(0xcafecafecafecafe)
14-
}
15-
}
16-
17-
func BenchmarkCount(b *testing.B) {
18-
for i := 0; i < b.N; i++ {
19-
Count(0xcafecafecafecafe)
20-
}
21-
}
22-
235
// Number of words in test set.
246
const nw = 1 << 10
257

funcs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const (
1414

1515
// LeadingZeros returns the number of leading zero bits in w;
1616
// it returns 64 when w is zero.
17+
//
18+
// Deprecated: In Go 1.9 this function is available in package math/bits as LeadingZeros64.
1719
func LeadingZeros(w uint64) int {
1820
// Fill word with ones on the right, e.g. 0x0000f308 -> 0x0000ffff.
1921
w |= w >> 1
@@ -27,6 +29,8 @@ func LeadingZeros(w uint64) int {
2729

2830
// TrailingZeros returns the number of trailing zero bits in w;
2931
// it returns 64 when w is zero.
32+
//
33+
// Deprecated: In Go 1.9 this function is available in package math/bits as TrailingZeros64.
3034
func TrailingZeros(w uint64) int {
3135
// “Using de Bruijn Sequences to Index a 1 in a Computer Word”,
3236
// Leiserson, Prokop, and Randall, MIT, 1998.
@@ -53,6 +57,8 @@ func init() {
5357
}
5458

5559
// Count returns the number of nonzero bits in w.
60+
//
61+
// Deprecated: In Go 1.9 this function is available in package math/bits as OnesCount64.
5662
func Count(w uint64) int {
5763
// “Software Optimization Guide for AMD64 Processors”, Section 8.6.
5864
const maxw = 1<<64 - 1

set.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build !go1.9
2+
13
// Package bit provides a bit array implementation
24
// and some utility bit functions.
35
//

0 commit comments

Comments
 (0)