Skip to content

Commit

Permalink
更新readme
Browse files Browse the repository at this point in the history
  • Loading branch information
guonaihong committed Jun 14, 2020
1 parent 0650ecf commit 5605053
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Binaries for programs and plugins
*.exe
*.exe~
*swp
*.dll
*.so
*.dylib
Expand Down
38 changes: 38 additions & 0 deletions list/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## list
list 是双向循环链表结构,具备较好的性能

## quick start
```go
import (
"fmt"
"unsafe"

"github.com/antlabs/stl/list"
)

type worker struct {
list.Head //内嵌到业务结构体里面
ID int
}

func main() {
workerHead := worker{} //声明
workerHead.Init() //初始化

n1 := worker{ID: 1}
n2 := worker{ID: 2}

workerHead.AddTail(&n1.Head) //添加到尾部
workerHead.AddTail(&n2.Head) //天骄到尾部

offset := unsafe.Offsetof(workerHead.Head)
//遍历
workerHead.ForEach(func(pos *list.Head) {

worker := (*worker)(pos.Entry(offset))

fmt.Printf("worker id:%d\n", worker.ID)
})
}

```

## 性能对比
性能领先go标准库1倍
Expand Down

0 comments on commit 5605053

Please sign in to comment.