Documentation ¶
Overview ¶
Package gset provides kinds of concurrent-safe/unsafe 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{}))
- func (set *IntSet) MarshalJSON() ([]byte, error)
- func (set *IntSet) Merge(others ...*IntSet) *IntSet
- func (set *IntSet) Pop() int
- func (set *IntSet) Pops(size int) []int
- func (set *IntSet) RLockFunc(f func(m map[int]struct{}))
- 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) Sum() (sum int)
- 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{}))
- func (set *Set) MarshalJSON() ([]byte, error)
- func (set *Set) Merge(others ...*Set) *Set
- func (set *Set) Pop() interface{}
- func (set *Set) Pops(size int) []interface{}
- func (set *Set) RLockFunc(f func(m map[interface{}]struct{}))
- 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) Sum() (sum int)
- func (set *Set) Union(others ...*Set) (newSet *Set)
- type StrSet
- func (set *StrSet) Add(item ...string) *StrSet
- func (set *StrSet) Clear() *StrSet
- func (set *StrSet) Complement(full *StrSet) (newSet *StrSet)
- func (set *StrSet) Contains(item string) bool
- func (set *StrSet) Diff(others ...*StrSet) (newSet *StrSet)
- func (set *StrSet) Equal(other *StrSet) bool
- func (set *StrSet) Intersect(others ...*StrSet) (newSet *StrSet)
- func (set *StrSet) IsSubsetOf(other *StrSet) bool
- func (set *StrSet) Iterator(f func(v string) bool) *StrSet
- func (set *StrSet) Join(glue string) string
- func (set *StrSet) LockFunc(f func(m map[string]struct{}))
- func (set *StrSet) MarshalJSON() ([]byte, error)
- func (set *StrSet) Merge(others ...*StrSet) *StrSet
- func (set *StrSet) Pop() string
- func (set *StrSet) Pops(size int) []string
- func (set *StrSet) RLockFunc(f func(m map[string]struct{}))
- func (set *StrSet) Remove(item string) *StrSet
- func (set *StrSet) Size() int
- func (set *StrSet) Slice() []string
- func (set *StrSet) String() string
- func (set *StrSet) Sum() (sum int)
- func (set *StrSet) Union(others ...*StrSet) (newSet *StrSet)
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 ¶
New create and returns a new set, which contains un-repeated items. The parameter <unsafe> used to specify whether using set in un-concurrent-safety, which is false in default.
func NewIntSetFrom ¶
NewIntSetFrom returns a new set from <items>.
func (*IntSet) Add ¶
Add adds one or multiple items to the set.
func (*IntSet) Complement ¶
Complement returns a new set which is the complement from <set> to <full>. Which means, all the items in <newSet> are in <full> and not in <set>.
It returns the difference between <full> and <set> if the given set <full> is not the full set of <set>.
func (*IntSet) Contains ¶
Contains checks whether the set contains <item>.
func (*IntSet) Diff ¶
Diff returns a new set which is the difference set from <set> to <other>. Which means, all the items in <newSet> are in <set> but not in <other>.
func (*IntSet) Equal ¶
Equal checks whether the two sets equal.
func (*IntSet) Intersect ¶
Intersect returns a new set which is the intersection from <set> to <other>. Which means, all the items in <newSet> are in <set> and also in <other>.
func (*IntSet) IsSubsetOf ¶
IsSubsetOf checks whether the current set is a sub-set of <other>.
func (*IntSet) Iterator ¶
Iterator iterates the set with given callback function <f>, if <f> returns true then continue iterating; or false to stop.
func (*IntSet) Join ¶
Join joins items with a string <glue>.
func (*IntSet) LockFunc ¶
LockFunc locks writing with callback function <f>.
func (*IntSet) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*IntSet) Merge ¶
Merge adds items from <others> sets into <set>.
func (*IntSet) Pops ¶
Pops randomly pops <size> items from set.
func (*IntSet) RLockFunc ¶
RLockFunc locks reading with callback function <f>.
func (*IntSet) Slice ¶
Slice returns the a of items of the set as slice.
func (*IntSet) String ¶
String returns items as a string, which are joined by char ','.
func (*IntSet) Sum ¶
Sum sums items. Note: The items should be converted to int type, or you'd get a result that you unexpected.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func New ¶
New create and returns a new set, which contains un-repeated items. The parameter <unsafe> used to specify whether using set in un-concurrent-safety, which is false in default.
func NewFrom ¶
NewFrom returns a new set from <items>. Parameter <items> can be either a variable of any type, or a slice.
func (*Set) Add ¶
Add adds one or multiple items to the set.
func (*Set) Complement ¶
Complement returns a new set which is the complement from <set> to <full>. Which means, all the items in <newSet> are in <full> and not in <set>.
It returns the difference between <full> and <set> if the given set <full> is not the full set of <set>.
func (*Set) Contains ¶
Contains checks whether the set contains <item>.
func (*Set) Diff ¶
Diff returns a new set which is the difference set from <set> to <others>. Which means, all the items in <newSet> are in <set> but not in <others>.
func (*Set) Intersect ¶
Intersect returns a new set which is the intersection from <set> to <others>. Which means, all the items in <newSet> are in <set> and also in <others>.
func (*Set) IsSubsetOf ¶
IsSubsetOf checks whether the current set is a sub-set of <other>.
func (*Set) Iterator ¶
Iterator iterates the set with given callback function <f>, if <f> returns true then continue iterating; or false to stop.
func (*Set) LockFunc ¶
func (set *Set) LockFunc(f func(m map[interface{}]struct{}))
LockFunc locks writing with callback function <f>.
func (*Set) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Set) Merge ¶
Merge adds items from <others> sets into <set>.
func (*Set) Pops ¶
Pops randomly pops <size> items from set.
func (*Set) RLockFunc ¶
func (set *Set) RLockFunc(f func(m map[interface{}]struct{}))
RLockFunc locks reading with callback function <f>.
func (*Set) Slice ¶
func (set *Set) Slice() []interface{}
Slice returns the a of items of the set as slice.
func (*Set) String ¶
String returns items as a string, which are joined by char ','.
func (*Set) Sum ¶
Sum sums items. Note: The items should be converted to int type, or you'd get a result that you unexpected.
type StrSet ¶
type StrSet struct {
// contains filtered or unexported fields
}
func NewStrSet ¶
New create and returns a new set, which contains un-repeated items. The parameter <unsafe> used to specify whether using set in un-concurrent-safety, which is false in default.
func NewStrSetFrom ¶
NewStrSetFrom returns a new set from <items>.
func (*StrSet) Add ¶
Add adds one or multiple items to the set.
func (*StrSet) Complement ¶
Complement returns a new set which is the complement from <set> to <full>. Which means, all the items in <newSet> are in <full> and not in <set>.
It returns the difference between <full> and <set> if the given set <full> is not the full set of <set>.
func (*StrSet) Contains ¶
Contains checks whether the set contains <item>.
func (*StrSet) Diff ¶
Diff returns a new set which is the difference set from <set> to <other>. Which means, all the items in <newSet> are in <set> but not in <other>.
func (*StrSet) Equal ¶
Equal checks whether the two sets equal.
func (*StrSet) Intersect ¶
Intersect returns a new set which is the intersection from <set> to <other>. Which means, all the items in <newSet> are in <set> and also in <other>.
func (*StrSet) IsSubsetOf ¶
IsSubsetOf checks whether the current set is a sub-set of <other>.
func (*StrSet) Iterator ¶
Iterator iterates the set with given callback function <f>, if <f> returns true then continue iterating; or false to stop.
func (*StrSet) Join ¶
Join joins items with a string <glue>.
func (*StrSet) LockFunc ¶
LockFunc locks writing with callback function <f>.
func (*StrSet) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*StrSet) Merge ¶
Merge adds items from <others> sets into <set>.
func (*StrSet) Pops ¶
Pops randomly pops <size> items from set.
func (*StrSet) RLockFunc ¶
RLockFunc locks reading with callback function <f>.
func (*StrSet) Remove ¶
Remove deletes <item> from set.
func (*StrSet) Slice ¶
Slice returns the a of items of the set as slice.
func (*StrSet) String ¶
String returns items as a string, which are joined by char ','.
func (*StrSet) Sum ¶
Sum sums items. Note: The items should be converted to int type, or you'd get a result that you unexpected.