File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package bitset
3
3
const word = uint64 (64 )
4
4
const logword = uint (6 )
5
5
6
- type BitSet struct {
6
+ type Bitset struct {
7
7
length uint64
8
8
bits []uint64
9
9
}
@@ -12,9 +12,9 @@ func getSize(length uint64) uint64 {
12
12
return uint64 ((length + word - 1 ) / word )
13
13
}
14
14
15
- func New (length uint64 ) * BitSet {
15
+ func New (length uint64 ) * Bitset {
16
16
size := getSize (length )
17
- return & BitSet {
17
+ return & Bitset {
18
18
length ,
19
19
make ([]uint64 , size ),
20
20
}
@@ -26,31 +26,31 @@ func getIndex(pos uint64) (q uint64, r uint) {
26
26
return
27
27
}
28
28
29
- func (b * BitSet ) Length () uint64 {
29
+ func (b * Bitset ) Length () uint64 {
30
30
return b .length
31
31
}
32
32
33
- func (b * BitSet ) Get (pos uint64 ) bool {
33
+ func (b * Bitset ) Get (pos uint64 ) bool {
34
34
q , r := getIndex (pos )
35
35
bit := (b .bits [q ] >> r ) & 1
36
36
return bit != 0
37
37
}
38
38
39
- func (b * BitSet ) Set (pos uint64 ) bool {
39
+ func (b * Bitset ) Set (pos uint64 ) bool {
40
40
current := b .Get (pos )
41
41
q , r := getIndex (pos )
42
42
b .bits [q ] |= (1 << r )
43
43
return current
44
44
}
45
45
46
- func (b * BitSet ) Clear (pos uint64 ) bool {
46
+ func (b * Bitset ) Clear (pos uint64 ) bool {
47
47
current := b .Get (pos )
48
48
q , r := getIndex (pos )
49
49
b .bits [q ] &= ^ (1 << r )
50
50
return current
51
51
}
52
52
53
- func (b * BitSet ) Flip (pos uint64 ) bool {
53
+ func (b * Bitset ) Flip (pos uint64 ) bool {
54
54
current := b .Get (pos )
55
55
q , r := getIndex (pos )
56
56
b .bits [q ] ^= (1 << r )
You can’t perform that action at this time.
0 commit comments