2 Star 0 Fork 1

web-bird/bird

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
map.go 706 Bytes
一键复制 编辑 原始数据 按行查看 历史
悟道人 提交于 2020-03-18 22:47 +08:00 . 修复部分bug
package utils
import "sync"
type MapInt64 struct {
data map[string]int64
sync.Mutex
}
func NewMapInt64() *MapInt64 {
return &MapInt64{data: make(map[string]int64)}
}
func (this *MapInt64) Data() map[string]int64 {
return this.data
}
func (this *MapInt64) Set(key string, val int64) {
this.Lock()
defer this.Unlock()
this.data[key] = val
}
func (this *MapInt64) Get(key string) int64 {
this.Lock()
defer this.Unlock()
return this.data[key]
}
func (this *MapInt64) Has(key string) (int64, bool) {
this.Lock()
defer this.Unlock()
data, has := this.data[key]
return data, has
}
func (this *MapInt64) Add(key string, val int64) {
this.Lock()
defer this.Unlock()
this.data[key] += val
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/web-bird/bird.git
git@gitee.com:web-bird/bird.git
web-bird
bird
bird
ac7d4c82d0c1

搜索帮助