gf: github.com/johng-cn/gf/g/container/gset Index | Files

package gset

import "github.com/johng-cn/gf/g/container/gset"

Package gset provides kinds of concurrent-safe(alternative) sets.

并发安全集合.

Index

Package Files

gset.go gset_int_set.go gset_string_set.go

type IntSet Uses

type IntSet struct {
    // contains filtered or unexported fields
}

func NewIntSet Uses

func NewIntSet(unsafe ...bool) *IntSet

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) Add Uses

func (set *IntSet) Add(item ...int) *IntSet

Add one or multiple items to the set.

添加元素项到集合中(支持多个).

func (*IntSet) Clear Uses

func (set *IntSet) Clear() *IntSet

Clear the set.

清空集合。

func (*IntSet) Complement Uses

func (set *IntSet) Complement(full *IntSet) (newSet *IntSet)

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) Contains Uses

func (set *IntSet) Contains(item int) bool

Check whether the set contains <item>.

键是否存在.

func (*IntSet) Diff Uses

func (set *IntSet) Diff(others ...*IntSet) (newSet *IntSet)

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) Equal Uses

func (set *IntSet) Equal(other *IntSet) bool

Check whether the two sets equal.

判断两个集合是否相等.

func (*IntSet) Intersect Uses

func (set *IntSet) Intersect(others ...*IntSet) (newSet *IntSet)

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 Uses

func (set *IntSet) IsSubsetOf(other *IntSet) bool

Check whether the current set is sub-set of <other>.

判断当前集合是否为other集合的子集.

func (*IntSet) Iterator Uses

func (set *IntSet) Iterator(f func(v int) bool) *IntSet

Iterate the set by given callback <f>, if <f> returns true then continue iterating; or false to stop.

给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历。

func (*IntSet) Join Uses

func (set *IntSet) Join(glue string) string

Join set items with a string.

使用glue字符串串连当前集合的元素项,构造成新的字符串返回。

func (*IntSet) LockFunc Uses

func (set *IntSet) LockFunc(f func(m map[int]struct{})) *IntSet

Lock writing by callback function f.

使用自定义方法执行加锁修改操作。

func (*IntSet) RLockFunc Uses

func (set *IntSet) RLockFunc(f func(m map[int]struct{})) *IntSet

Lock reading by callback function f.

使用自定义方法执行加锁读取操作。

func (*IntSet) Remove Uses

func (set *IntSet) Remove(item int) *IntSet

Remove <item> from set.

删除元素项。

func (*IntSet) Size Uses

func (set *IntSet) Size() int

Get size of the set.

获得集合大小。

func (*IntSet) Slice Uses

func (set *IntSet) Slice() []int

Get the copy of items from set as slice.

获得集合元素项列表.

func (*IntSet) String Uses

func (set *IntSet) String() string

Return set items as a string, which are joined by char ','.

使用glue字符串串连当前集合的元素项,构造成新的字符串返回。

func (*IntSet) Union Uses

func (set *IntSet) Union(others ...*IntSet) (newSet *IntSet)

Returns a new set which is the union of <set> and <other>. Which means, all the items in <newSet> is in <set> or in <other>.

并集, 返回新的集合:属于set或属于others的元素为元素的集合.

type Set Uses

type Set struct {
    // contains filtered or unexported fields
}

func New Uses

func New(unsafe ...bool) *Set

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 NewSet Uses

func NewSet(unsafe ...bool) *Set

See New.

同New.

func (*Set) Add Uses

func (set *Set) Add(item ...interface{}) *Set

Add one or multiple items to the set.

添加元素项到集合中(支持多个).

func (*Set) Clear Uses

func (set *Set) Clear() *Set

Clear the set.

清空集合。

func (*Set) Complement Uses

func (set *Set) Complement(full *Set) (newSet *Set)

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) Contains Uses

func (set *Set) Contains(item interface{}) bool

Check whether the set contains <item>.

键是否存在.

func (*Set) Diff Uses

func (set *Set) Diff(others ...*Set) (newSet *Set)

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) Equal Uses

func (set *Set) Equal(other *Set) bool

Check whether the two sets equal.

判断两个集合是否相等.

func (*Set) Intersect Uses

func (set *Set) Intersect(others ...*Set) (newSet *Set)

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) IsSubsetOf Uses

func (set *Set) IsSubsetOf(other *Set) bool

Check whether the current set is sub-set of <other>.

判断当前集合是否为other集合的子集.

func (*Set) Iterator Uses

func (set *Set) Iterator(f func(v interface{}) bool) *Set

Iterate the set by given callback <f>, if <f> returns true then continue iterating; or false to stop.

给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历。

func (*Set) Join Uses

func (set *Set) Join(glue string) string

Join set items with a string.

使用glue字符串串连当前集合的元素项,构造成新的字符串返回。

func (*Set) LockFunc Uses

func (set *Set) LockFunc(f func(m map[interface{}]struct{})) *Set

Lock writing by callback function f.

使用自定义方法执行加锁修改操作。

func (*Set) RLockFunc Uses

func (set *Set) RLockFunc(f func(m map[interface{}]struct{})) *Set

Lock reading by callback function f.

使用自定义方法执行加锁读取操作。

func (*Set) Remove Uses

func (set *Set) Remove(item interface{}) *Set

Remove <item> from set.

删除元素项。

func (*Set) Size Uses

func (set *Set) Size() int

Get size of the set.

获得集合大小。

func (*Set) Slice Uses

func (set *Set) Slice() []interface{}

Get the copy of items from set as slice.

获得集合元素项列表.

func (*Set) String Uses

func (set *Set) String() string

Return set items as a string, which are joined by char ','.

使用glue字符串串连当前集合的元素项,构造成新的字符串返回。

func (*Set) Union Uses

func (set *Set) Union(others ...*Set) (newSet *Set)

Returns a new set which is the union of <set> and <other>. Which means, all the items in <newSet> is in <set> or in <other>.

并集, 返回新的集合:属于set或属于others的元素为元素的集合.

type StringSet Uses

type StringSet struct {
    // contains filtered or unexported fields
}

func NewStringSet Uses

func NewStringSet(unsafe ...bool) *StringSet

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) Add Uses

func (set *StringSet) Add(item ...string) *StringSet

Add one or multiple items to the set.

添加元素项到集合中(支持多个).

func (*StringSet) Clear Uses

func (set *StringSet) Clear() *StringSet

Clear the set.

清空集合。

func (*StringSet) Complement Uses

func (set *StringSet) Complement(full *StringSet) (newSet *StringSet)

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) Contains Uses

func (set *StringSet) Contains(item string) bool

Check whether the set contains <item>.

键是否存在.

func (*StringSet) Diff Uses

func (set *StringSet) Diff(others ...*StringSet) (newSet *StringSet)

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) Equal Uses

func (set *StringSet) Equal(other *StringSet) bool

Check whether the two sets equal.

判断两个集合是否相等.

func (*StringSet) Intersect Uses

func (set *StringSet) Intersect(others ...*StringSet) (newSet *StringSet)

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 Uses

func (set *StringSet) IsSubsetOf(other *StringSet) bool

Check whether the current set is sub-set of <other>.

判断当前集合是否为other集合的子集.

func (*StringSet) Iterator Uses

func (set *StringSet) Iterator(f func(v string) bool) *StringSet

Iterate the set by given callback <f>, if <f> returns true then continue iterating; or false to stop.

给定回调函数对原始内容进行遍历,回调函数返回true表示继续遍历,否则停止遍历。

func (*StringSet) Join Uses

func (set *StringSet) Join(glue string) string

Join set items with a string.

使用glue字符串串连当前集合的元素项,构造成新的字符串返回。

func (*StringSet) LockFunc Uses

func (set *StringSet) LockFunc(f func(m map[string]struct{})) *StringSet

Lock writing by callback function f.

使用自定义方法执行加锁修改操作。

func (*StringSet) RLockFunc Uses

func (set *StringSet) RLockFunc(f func(m map[string]struct{})) *StringSet

Lock reading by callback function f.

使用自定义方法执行加锁读取操作。

func (*StringSet) Remove Uses

func (set *StringSet) Remove(item string) *StringSet

Remove <item> from set.

删除元素项。

func (*StringSet) Size Uses

func (set *StringSet) Size() int

Get size of the set.

获得集合大小。

func (*StringSet) Slice Uses

func (set *StringSet) Slice() []string

Get the copy of items from set as slice.

获得集合元素项列表.

func (*StringSet) String Uses

func (set *StringSet) String() string

Return set items as a string, which are joined by char ','.

使用glue字符串串连当前集合的元素项,构造成新的字符串返回。

func (*StringSet) Union Uses

func (set *StringSet) Union(others ...*StringSet) (newSet *StringSet)

Returns a new set which is the union of <set> and <other>. Which means, all the items in <newSet> is in <set> or in <other>.

并集, 返回新的集合:属于set或属于others的元素为元素的集合.

Package gset imports 3 packages (graph). Updated 2019-03-22. Refresh now. Tools for package owners.