Skip to content

Commit 0daee48

Browse files
committed
feat: 实现bool array
1 parent 283e475 commit 0daee48

File tree

7 files changed

+108
-1
lines changed

7 files changed

+108
-1
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### Go template
2+
# If you prefer the allow list template instead of the deny list, see community template:
3+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
4+
#
5+
# Binaries for programs and plugins
6+
*.exe
7+
*.exe~
8+
*.dll
9+
*.so
10+
*.dylib
11+
12+
# Test binary, built with `go test -c`
13+
*.test
14+
15+
# Output of the go coverage tool, specifically when used with LiteIDE
16+
*.out
17+
18+
# Dependency directories (remove the comment below to include it)
19+
# vendor/
20+
21+
# Go workspace file
22+
go.work
23+
24+
.idea

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# go-bool
2+
3+
# 一、这是什么?
4+
5+
更节省内容的布尔值:
6+
7+
- 数组(已实现)
8+
- 矩阵(待实现)
9+
10+
# 二、安装
11+
12+
```bash
13+
go get -u github.com/compression-algorithm-research-lab/go-bool
14+
```
15+
16+
# 三、API示例
17+
18+
```go
19+
package main
20+
21+
import (
22+
"fmt"
23+
"github.com/compression-algorithm-research-lab/go-bool/bool_array"
24+
)
25+
26+
func main() {
27+
28+
array := bool_array.New(10)
29+
array.Set(1, true)
30+
fmt.Println(array.Get(1))
31+
32+
}
33+
```
34+
35+
36+
37+
38+

pkg/bool_array/array.go bool_array/array.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import (
55
if_expression "github.com/golang-infrastructure/go-if-expression"
66
)
77

8+
// BoolArray 布尔数组
89
type BoolArray struct {
9-
values []byte
10+
11+
// 数组的值
12+
values []byte
13+
14+
// 数组的容量
1015
capacity int
1116
}
1217

File renamed without changes.

examples/main.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/compression-algorithm-research-lab/go-bool/bool_array"
6+
)
7+
8+
func main() {
9+
10+
array := bool_array.New(10)
11+
array.Set(1, true)
12+
fmt.Println(array.Get(1))
13+
14+
}

go.mod

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module github.com/compression-algorithm-research-lab/go-bool
2+
3+
go 1.18
4+
5+
require (
6+
github.com/golang-infrastructure/go-if-expression v0.0.3
7+
github.com/stretchr/testify v1.8.4
8+
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/pmezard/go-difflib v1.0.0 // indirect
13+
gopkg.in/yaml.v3 v3.0.1 // indirect
14+
)

go.sum

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/golang-infrastructure/go-if-expression v0.0.3 h1:Ic6L/s250nwtQz8CtTFpkWopCwsWmxQErSRkrBqBVj4=
4+
github.com/golang-infrastructure/go-if-expression v0.0.3/go.mod h1:U4ZtU29/RtZ/cM0tAdBzFaFxENFShSFj+jCRFRE/cv4=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
8+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
12+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)