Documentation
¶
Index ¶
- type IntSet
- func (set *IntSet) Add(items ...int)
- func (set *IntSet) Contains(item int) bool
- func (set *IntSet) Intersect(others ...*IntSet) *IntSet
- func (set *IntSet) Iterator(f func(v int) bool)
- func (set *IntSet) MarshalJSON() ([]byte, error)
- func (set *IntSet) Pop() int
- func (set *IntSet) Remove(items ...int)
- func (set *IntSet) Size() int
- func (set *IntSet) Slice() []int
- func (set *IntSet) String() string
- func (set *IntSet) Sum() (sum int)
- func (set *IntSet) Union(others ...*IntSet) *IntSet
- func (set *IntSet) UnmarshalJSON(b []byte) error
- type Set
- func (set *Set) Add(items ...interface{})
- func (set *Set) AddIfNotExist(item interface{}) bool
- func (set *Set) Clear()
- func (set *Set) Contains(item interface{}) bool
- func (set *Set) Intersect(others ...*Set) *Set
- func (set *Set) Iterator(f func(v interface{}) bool)
- func (set *Set) Remove(items ...interface{})
- func (set *Set) RemoveAll(other *Set)
- func (set *Set) Size() int
- func (set *Set) Slice() []interface{}
- func (set *Set) String() string
- func (set *Set) Union(others ...*Set) *Set
- type StrSet
- func (set *StrSet) Add(items ...string)
- func (set *StrSet) AddIfNotExist(item string) bool
- func (set *StrSet) AddIfNotExistFunc(item string, f func() bool) bool
- func (set *StrSet) AddIfNotExistFuncLock(item string, f func() bool) bool
- func (set *StrSet) Clear()
- func (set *StrSet) Contains(item string) bool
- func (set *StrSet) ContainsI(item string) bool
- func (set *StrSet) Intersect(others ...*StrSet) *StrSet
- func (set *StrSet) Iterator(f func(v string) bool)
- func (set *StrSet) MarshalJSON() ([]byte, error)
- func (set *StrSet) Remove(items ...string)
- func (set *StrSet) Size() int
- func (set *StrSet) Slice() []string
- func (set *StrSet) String() string
- func (set *StrSet) Union(others ...*StrSet) *StrSet
- func (set *StrSet) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntSet ¶
type IntSet struct {
// contains filtered or unexported fields
}
IntSet 存储不重复的整数集合
func NewIntSetFrom ¶
NewIntSetFrom 从整数切片创建新的集合
func (*IntSet) MarshalJSON ¶
MarshalJSON 实现 json.Marshal 接口
func (*IntSet) UnmarshalJSON ¶
UnmarshalJSON 实现 json.Unmarshal 接口
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set 是一个通用的集合类型,存储不重复的items
func (*Set) AddIfNotExist ¶
AddIfNotExist 如果元素不存在则添加并返回true,否则返回false
type StrSet ¶
type StrSet struct {
// contains filtered or unexported fields
}
StrSet 存储不重复的字符串集合
func NewStrSetFrom ¶
NewStrSetFrom 从字符串切片创建新的集合
func (*StrSet) AddIfNotExist ¶
AddIfNotExist 检查集合中是否存在项目, 它将该项添加到set中,如果该项在set中不存在,则返回true, 否则它什么也不做,返回false。
func (*StrSet) AddIfNotExistFunc ¶
AddIfNotExistFunc 检查集合中是否存在项目, 它将该项添加到set中,如果该项在set中不存在,则返回true,并且 函数`f`返回true,否则它什么也不做,返回false。
请注意,函数“f”是在没有写锁的情况下执行的。
func (*StrSet) AddIfNotExistFuncLock ¶
AddIfNotExistFuncLock 检查集合中是否存在项目, 它将该项添加到set中,如果该项在set中不存在,则返回true,并且 函数`f`返回true,否则它什么也不做,返回false。
请注意,函数“f”是在没有写锁的情况下执行的。
func (*StrSet) MarshalJSON ¶
MarshalJSON 实现 json.Marshaler 接口
func (*StrSet) UnmarshalJSON ¶
UnmarshalJSON 实现 json.Unmarshaler 接口
Click to show internal directories.
Click to hide internal directories.