This repository has been archived by the owner on Sep 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpopcount_slices.go
123 lines (110 loc) · 1.96 KB
/
popcount_slices.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// Package hamming distance calculations in Go
//
// https://github.com/steakknife/hamming
//
// Copyright © 2014, 2015, 2016, 2018 Barry Allard
//
// MIT license
//
package hamming
// CountBitsInt8s count 1's in b
func CountBitsInt8s(b []int8) int {
c := 0
for _, x := range b {
c += CountBitsInt8(x)
}
return c
}
// CountBitsInt16s count 1's in b
func CountBitsInt16s(b []int16) int {
c := 0
for _, x := range b {
c += CountBitsInt16(x)
}
return c
}
// CountBitsInt32s count 1's in b
func CountBitsInt32s(b []int32) int {
c := 0
for _, x := range b {
c += CountBitsInt32(x)
}
return c
}
// CountBitsInt64s count 1's in b
func CountBitsInt64s(b []int64) int {
c := 0
for _, x := range b {
c += CountBitsInt64(x)
}
return c
}
// CountBitsInts count 1's in b
func CountBitsInts(b []int) int {
c := 0
for _, x := range b {
c += CountBitsInt(x)
}
return c
}
// CountBitsUint8s count 1's in b
func CountBitsUint8s(b []uint8) int {
c := 0
for _, x := range b {
c += CountBitsUint8(x)
}
return c
}
// CountBitsUint16s count 1's in b
func CountBitsUint16s(b []uint16) int {
c := 0
for _, x := range b {
c += CountBitsUint16(x)
}
return c
}
// CountBitsUint32s count 1's in b
func CountBitsUint32s(b []uint32) int {
c := 0
for _, x := range b {
c += CountBitsUint32(x)
}
return c
}
// CountBitsUint64s count 1's in b
func CountBitsUint64s(b []uint64) int {
c := 0
for _, x := range b {
c += CountBitsUint64(x)
}
return c
}
// CountBitsUints count 1's in b
func CountBitsUints(b []uint) int {
c := 0
for _, x := range b {
c += CountBitsUint(x)
}
return c
}
// CountBitsBytes count 1's in b
func CountBitsBytes(b []byte) int {
c := 0
for _, x := range b {
c += CountBitsByte(x)
}
return c
}
// CountBitsRunes count 1's in b
func CountBitsRunes(b []rune) int {
c := 0
for _, x := range b {
c += CountBitsRune(x)
}
return c
}
// CountBitsString count 1's in s
func CountBitsString(s string) int {
return CountBitsBytes([]byte(s))
}