File tree Expand file tree Collapse file tree 4 files changed +27
-6
lines changed
Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ jobs:
1515 runs-on : ubuntu-latest
1616 steps :
1717
18+ - name : Check out code into the Go module directory
19+ uses : actions/checkout@v5
20+
1821 - name : Set up Go 1.x
19- uses : actions/setup-go@v2
22+ uses : actions/setup-go@v6
2023 with :
2124 go-version : 1.x
2225 id : go
2326
24- - name : Check out code into the Go module directory
25- uses : actions/checkout@v2
26-
2727 - name : Build
2828 run : go build -v ./...
2929
Original file line number Diff line number Diff line change 11# variable-lenght bitfield
22
3- [ ![ GoDoc ] ( https://godoc.org/ github.com/dim13/bit?status .svg )] ( https://godoc.org /github.com/dim13/bit )
4- [ ![ Build ] ( https://github.com/dim13/bit/workflows/build /badge.svg )] ( https://github.com/dim13/bit/actions )
3+ [ ![ Go Reference ] ( https://pkg.go.dev/badge/ github.com/dim13/bit.svg )] ( https://pkg.go.dev /github.com/dim13/bit )
4+ [ ![ Go ] ( https://github.com/dim13/bit/actions/ workflows/go.yml /badge.svg )] ( https://github.com/dim13/bit/actions/workflows/go.yml )
Original file line number Diff line number Diff line change @@ -32,3 +32,12 @@ func (f *Field) IsClear(k int) bool {
3232 n , m := k >> 3 , byte (1 << uint (k & 7 ))
3333 return len (* f ) <= n || (* f )[n ]& m == 0
3434}
35+
36+ func (f * Field ) Shrink () {
37+ for i := len (* f ); i > 0 ; i -- {
38+ if (* f )[i - 1 ] != 0 {
39+ break
40+ }
41+ * f = (* f )[:i - 1 ]
42+ }
43+ }
Original file line number Diff line number Diff line change @@ -18,3 +18,15 @@ func TestBit(t *testing.T) {
1818 }
1919 }
2020}
21+
22+ func TestShrink (t * testing.T ) {
23+ bf := new (Field )
24+ bf .Set (0 )
25+ bf .Set (32 )
26+ bf .Set (64 )
27+ t .Log (bf )
28+ bf .Clear (64 )
29+ bf .Shrink ()
30+ bf .Set (128 )
31+ t .Log (bf )
32+ }
You can’t perform that action at this time.
0 commit comments