gset

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gset provides kinds of concurrent-safe/unsafe sets.

Index

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

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

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

Add one or multiple items to the set.

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

func (*IntSet) Clear

func (set *IntSet) Clear() *IntSet

Clear the set.

清空集合。

func (*IntSet) Complement

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

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

Check whether the set contains <item>.

键是否存在.

func (*IntSet) Diff

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

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

Check whether the two sets equal.

判断两个集合是否相等.

func (*IntSet) Intersect

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

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

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

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

func (*IntSet) Iterator

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

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

Join set items with a string.

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

func (*IntSet) LockFunc

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

Lock writing by callback function f.

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

func (*IntSet) RLockFunc

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

Lock reading by callback function f.

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

func (*IntSet) Remove

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

Remove <item> from set.

删除元素项。

func (*IntSet) Size

func (set *IntSet) Size() int

Get size of the set.

获得集合大小。

func (*IntSet) Slice

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

Get the copy of items from set as slice.

获得集合元素项列表.

func (*IntSet) String

func (set *IntSet) String() string

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

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

func (*IntSet) Union

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

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

func New

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

func NewSet(unsafe ...bool) *Set

See New.

同New.

func (*Set) Add

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

Add one or multiple items to the set.

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

func (*Set) Clear

func (set *Set) Clear() *Set

Clear the set.

清空集合。

func (*Set) Complement

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

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

Check whether the set contains <item>.

键是否存在.

func (*Set) Diff

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

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

Check whether the two sets equal.

判断两个集合是否相等.

func (*Set) Intersect

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

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

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

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

func (*Set) Iterator

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

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

Join set items with a string.

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

func (*Set) LockFunc

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

Lock writing by callback function f.

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

func (*Set) RLockFunc

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

Lock reading by callback function f.

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

func (*Set) Remove

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

Remove <item> from set.

删除元素项。

func (*Set) Size

func (set *Set) Size() int

Get size of the set.

获得集合大小。

func (*Set) Slice

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

Get the copy of items from set as slice.

获得集合元素项列表.

func (*Set) String

func (set *Set) String() string

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

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

func (*Set) Union

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

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

func NewStringSet

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

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

Add one or multiple items to the set.

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

func (*StringSet) Clear

func (set *StringSet) Clear() *StringSet

Clear the set.

清空集合。

func (*StringSet) Complement

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

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

Check whether the set contains <item>.

键是否存在.

func (*StringSet) Diff

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

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

Check whether the two sets equal.

判断两个集合是否相等.

func (*StringSet) Intersect

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

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

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

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

func (*StringSet) Iterator

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

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

Join set items with a string.

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

func (*StringSet) LockFunc

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

Lock writing by callback function f.

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

func (*StringSet) RLockFunc

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

Lock reading by callback function f.

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

func (*StringSet) Remove

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

Remove <item> from set.

删除元素项。

func (*StringSet) Size

func (set *StringSet) Size() int

Get size of the set.

获得集合大小。

func (*StringSet) Slice

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

Get the copy of items from set as slice.

获得集合元素项列表.

func (*StringSet) String

func (set *StringSet) String() string

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

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

func (*StringSet) Union

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的元素为元素的集合.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL