代码拉取完成,页面将自动刷新
package list
import "gitee.com/kristas/booting-go/framework/common/util/ccmap"
type ConcurrentSets struct {
cm *ccmap.ConcurrentMap
}
func NewConcurrentSets(arr ...string) (s *ConcurrentSets) {
s = &ConcurrentSets{
cm: ccmap.NewConcurrentMap(),
}
s.PutAll(arr...)
return
}
func (r *ConcurrentSets) Put(s string) {
r.cm.Set(s, struct{}{})
}
func (r *ConcurrentSets) PutAll(arr ...string) {
for _, s := range arr {
r.Put(s)
}
}
func (r *ConcurrentSets) ToArray() (arr []string) {
r.cm.ForEach(func(k string, v interface{}) {
arr = append(arr, k)
})
return
}
func (r *ConcurrentSets) Exists(t string) (ok bool) {
return r.cm.Exists(t)
}
func (r *ConcurrentSets) ExistsAny(t ...string) (ok bool) {
for _, s := range t {
if r.Exists(s) {
return true
}
}
return false
}
func (r *ConcurrentSets) ExistsAll(t ...string) (ok bool) {
for _, s := range t {
if !r.Exists(s) {
return false
}
}
return true
}
func (r *ConcurrentSets) Remove(s string) {
r.cm.Delete(s)
}
func (r *ConcurrentSets) RemoveAll(arr ...string) {
for _, s := range arr {
r.Remove(s)
}
}
func (r *ConcurrentSets) Length() int {
return r.cm.Size()
}
func (r *ConcurrentSets) ForEach(accept func(key string)) {
r.cm.ForEach(func(k string, v interface{}) {
accept(k)
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。