feat(gslice): initial set capacity for union (#31)
feat(gslice): initial set capacity for union
test: add benchmark
Update gslice/gslice_bench_test.go
Co-authored-by: Shengyu Zhang i@silverrainz.me
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
gg: Go Generics
English | 简体中文
🔥
bytedance/ggis a basic library of generics for Go language developed by ByteDance. It is based on the Go 1.18+ generic features and provides efficient, type-safe and rich generic data structures and tool functions.❓Why this name?
Take the first letter of Go Generics, short and simple.
❓Why choose gg?
🚀 Install
🔎 Table of contents
(T, bool)(T, error)T*T[]Tmap[K]Vfuncsyncmap[T]struct{}sync.Mapbelow Go 1.24sync.Mapbelow Go 1.24✨ Generic Functional Programming
goption
Option type, simplifying the processing of
(T, bool)Usage:
Example:
gresult
Result type, simplifying the processing of
(T, error)Usage:
Example:
✨ Generic Data Processing
gcond:
Conditional operation
Usage:
Example:
gvalue
Processing value
TUsage:
Example1:Zero Value
Example2:Math Operation
Example3:Comparison
Example4:Type Assertion
gptr
Processing pointer
*TUsage:
Example:
gslice
Processing slice
[]TUsage:
Example1:High-order Function
Example2:CURD Operation
Example3:Partion Operation
Example4:Math Operation
Example5:Convert to map
Example6:Set Operation
Example7:Re-order Operation
gmap
Processing map
map[K]VUsage:
Example1:Keys / Values Getter
Example2:High-order Function
Example3:CURD Operation
Example4:Partion Operation
Example5:Math Operation
Example6:Set Operation
gfunc
Processing function
funcUsage:
Example1:Partial Application
gconv
Data type conversion
Usage:
Example:
gson
Processing JSON
Usage:
Example:
✨ Generic Standard Wrapper
gsync
Wrap
syncUsage:
Example1:
gsync.Mapwrapssync.MapExample2:
gsync.Poolwrapssync.PoolExample3:
gsync.OnceXXXwrapssync.Once✨ Generic Data Structures
tuple
Implementation of tuple provides definition of generic n-ary tuples
Usage
Example:
set
Implementation of set based on
map[T]struct{}Usage
Example:
list
Implementation of doubly linked list
Usage
Example:
skipset
High-performance, scalable, concurrent-safe set based on skip-list, up to 15x faster than the built-in
sync.Mapbelow Go 1.24⚠️ NOTICE: Go 1.24 or later, please consider using the std
sync.Map, which has better performance compared toskipsetin about 90% of use cases.Usage
Example:
skipmap
High-performance, scalable, concurrent-safe map based on skip-list, up to 10x faster than the built-in
sync.Mapbelow Go 1.24⚠️ Go 1.24 or later, please consider using the std
sync.Map, which has better performance compared toskipmapin about 90% of use cases.Usage
Example:
License
ggis licensed under the Apache-2.0 license. See LICENSE for details.2025 © Bytedance