1 Star 4 Fork 0

magicianlyx / GoTask

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
set.go 371 Bytes
一键复制 编辑 原始数据 按行查看 历史
lrf123456 提交于 2019-08-22 14:24 . -
package structure
import (
"sync"
)
// 无序集合 线程安全
type Set struct {
s sync.Map
}
func NewSet() *Set {
return &Set{sync.Map{}}
}
func (s *Set) IsExist(key interface{}) bool {
_, isExist := s.s.Load(key)
return isExist
}
func (s *Set) Add(key interface{}) {
s.s.Store(key, struct{}{})
}
func (s *Set) Delete(key interface{}) {
s.s.Delete(key)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/magicianlyx/GoTask.git
git@gitee.com:magicianlyx/GoTask.git
magicianlyx
GoTask
GoTask
v1.0.15

搜索帮助

344bd9b3 5694891 D2dac590 5694891