Documentation ¶
Overview ¶
Package gset provides kinds of concurrent-safe(alternative) sets.
并发安全集合.
Index ¶
- type IntSet
- func (set *IntSet) Add(item ...int) *IntSet
- func (set *IntSet) Clear() *IntSet
- func (set *IntSet) Complement(full *IntSet) (newSet *IntSet)
- func (set *IntSet) Contains(item int) bool
- func (set *IntSet) Diff(others ...*IntSet) (newSet *IntSet)
- func (set *IntSet) Equal(other *IntSet) bool
- func (set *IntSet) Intersect(others ...*IntSet) (newSet *IntSet)
- func (set *IntSet) IsSubsetOf(other *IntSet) bool
- func (set *IntSet) Iterator(f func(v int) bool) *IntSet
- func (set *IntSet) Join(glue string) string
- func (set *IntSet) LockFunc(f func(m map[int]struct{})) *IntSet
- func (set *IntSet) RLockFunc(f func(m map[int]struct{})) *IntSet
- func (set *IntSet) Remove(item int) *IntSet
- func (set *IntSet) Size() int
- func (set *IntSet) Slice() []int
- func (set *IntSet) String() string
- func (set *IntSet) Union(others ...*IntSet) (newSet *IntSet)
- type Set
- func (set *Set) Add(item ...interface{}) *Set
- func (set *Set) Clear() *Set
- func (set *Set) Complement(full *Set) (newSet *Set)
- func (set *Set) Contains(item interface{}) bool
- func (set *Set) Diff(others ...*Set) (newSet *Set)
- func (set *Set) Equal(other *Set) bool
- func (set *Set) Intersect(others ...*Set) (newSet *Set)
- func (set *Set) IsSubsetOf(other *Set) bool
- func (set *Set) Iterator(f func(v interface{}) bool) *Set
- func (set *Set) Join(glue string) string
- func (set *Set) LockFunc(f func(m map[interface{}]struct{})) *Set
- func (set *Set) RLockFunc(f func(m map[interface{}]struct{})) *Set
- func (set *Set) Remove(item interface{}) *Set
- func (set *Set) Size() int
- func (set *Set) Slice() []interface{}
- func (set *Set) String() string
- func (set *Set) Union(others ...*Set) (newSet *Set)
- type StringSet
- func (set *StringSet) Add(item ...string) *StringSet
- func (set *StringSet) Clear() *StringSet
- func (set *StringSet) Complement(full *StringSet) (newSet *StringSet)
- func (set *StringSet) Contains(item string) bool
- func (set *StringSet) Diff(others ...*StringSet) (newSet *StringSet)
- func (set *StringSet) Equal(other *StringSet) bool
- func (set *StringSet) Intersect(others ...*StringSet) (newSet *StringSet)
- func (set *StringSet) IsSubsetOf(other *StringSet) bool
- func (set *StringSet) Iterator(f func(v string) bool) *StringSet
- func (set *StringSet) Join(glue string) string
- func (set *StringSet) LockFunc(f func(m map[string]struct{})) *StringSet
- func (set *StringSet) RLockFunc(f func(m map[string]struct{})) *StringSet
- func (set *StringSet) Remove(item string) *StringSet
- func (set *StringSet) Size() int
- func (set *StringSet) Slice() []string
- func (set *StringSet) String() string
- func (set *StringSet) Union(others ...*StringSet) (newSet *StringSet)
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
}
func NewIntSet ¶
Create a set, which contains un-repeated items. The param <unsafe> used to specify whether using array with un-concurrent-safety, which is false in default, means concurrent-safe in default.
创建一个空的集合对象,参数unsafe用于指定是否用于非并发安全场景,默认为false,表示并发安全。
func (*IntSet) Complement ¶
Returns a new set which is the complement from <set> to <full>. Which means, all the items in <newSet> is in <full> and not in <set>.
补集, 返回新的集合: (前提: set应当为full的子集)属于全集full不属于集合set的元素组成的集合. 如果给定的full集合不是set的全集时,返回full与set的差集.
func (*IntSet) Diff ¶
Returns a new set which is the difference set from <set> to <other>. Which means, all the items in <newSet> is in <set> and not in <other>.
差集, 返回新的集合: 属于set且不属于others的元素为元素的集合.
func (*IntSet) Intersect ¶
Returns a new set which is the intersection from <set> to <other>. Which means, all the items in <newSet> is in <set> and also in <other>.
交集, 返回新的集合: 属于set且属于others的元素为元素的集合.
func (*IntSet) IsSubsetOf ¶
Check whether the current set is sub-set of <other>.
判断当前集合是否为other集合的子集.
func (*IntSet) Iterator ¶
Iterate the set by given callback <f>, if <f> returns true then continue iterating; or false to stop.
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历。
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func New ¶
Create a set, which contains un-repeated items. The param <unsafe> used to specify whether using array with un-concurrent-safety, which is false in default, means concurrent-safe in default.
创建一个空的集合对象,参数unsafe用于指定是否用于非并发安全场景,默认为false,表示并发安全。
func (*Set) Complement ¶
Returns a new set which is the complement from <set> to <full>. Which means, all the items in <newSet> is in <full> and not in <set>.
补集, 返回新的集合: (前提: set应当为full的子集)属于全集full不属于集合set的元素组成的集合. 如果给定的full集合不是set的全集时,返回full与set的差集.
func (*Set) Diff ¶
Returns a new set which is the difference set from <set> to <other>. Which means, all the items in <newSet> is in <set> and not in <other>.
差集, 返回新的集合: 属于set且不属于others的元素为元素的集合.
func (*Set) Intersect ¶
Returns a new set which is the intersection from <set> to <other>. Which means, all the items in <newSet> is in <set> and also in <other>.
交集, 返回新的集合: 属于set且属于others的元素为元素的集合.
func (*Set) Iterator ¶
Iterate the set by given callback <f>, if <f> returns true then continue iterating; or false to stop.
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历。
func (*Set) Slice ¶
func (set *Set) Slice() []interface{}
Get the copy of items from set as slice.
获得集合元素项列表.
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
func NewStringSet ¶
Create a set, which contains un-repeated items. The param <unsafe> used to specify whether using array with un-concurrent-safety, which is false in default, means concurrent-safe in default.
创建一个空的集合对象,参数unsafe用于指定是否用于非并发安全场景,默认为false,表示并发安全。
func (*StringSet) Complement ¶
Returns a new set which is the complement from <set> to <full>. Which means, all the items in <newSet> is in <full> and not in <set>.
补集, 返回新的集合: (前提: set应当为full的子集)属于全集full不属于集合set的元素组成的集合. 如果给定的full集合不是set的全集时,返回full与set的差集.
func (*StringSet) Diff ¶
Returns a new set which is the difference set from <set> to <other>. Which means, all the items in <newSet> is in <set> and not in <other>.
差集, 返回新的集合: 属于set且不属于others的元素为元素的集合.
func (*StringSet) Intersect ¶
Returns a new set which is the intersection from <set> to <other>. Which means, all the items in <newSet> is in <set> and also in <other>.
交集, 返回新的集合: 属于set且属于others的元素为元素的集合.
func (*StringSet) IsSubsetOf ¶
Check whether the current set is sub-set of <other>.
判断当前集合是否为other集合的子集.
func (*StringSet) Iterator ¶
Iterate the set by given callback <f>, if <f> returns true then continue iterating; or false to stop.
给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历。