gf: github.com/gogf/gf/g/container/gset Index | Files

package gset

import "github.com/gogf/gf/g/container/gset"

Package gset provides kinds of concurrent-safe/unsafe 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

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 Uses

func NewIntSetFrom(items []int, unsafe ...bool) *IntSet

NewIntSetFrom returns a new set from <items>.

func (*IntSet) Add Uses

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

Add adds one or multiple items to the set.

func (*IntSet) Clear Uses

func (set *IntSet) Clear() *IntSet

Clear deletes all items of the set.

func (*IntSet) Complement Uses

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

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 Uses

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

Contains checks whether the set contains <item>.

func (*IntSet) Diff Uses

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

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 Uses

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

Equal checks whether the two sets equal.

func (*IntSet) Intersect Uses

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

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 Uses

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

IsSubsetOf checks whether the current set is a sub-set of <other>.

func (*IntSet) Iterator Uses

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

Iterator iterates the set with given callback function <f>, if <f> returns true then continue iterating; or false to stop.

func (*IntSet) Join Uses

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

Join joins items with a string <glue>.

func (*IntSet) LockFunc Uses

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

LockFunc locks writing with callback function <f>.

func (*IntSet) Merge Uses

func (set *IntSet) Merge(others ...*IntSet) *IntSet

Merge adds items from <others> sets into <set>.

func (*IntSet) Pop Uses

func (set *IntSet) Pop(size int) int

Pops randomly pops an item from set.

func (*IntSet) Pops Uses

func (set *IntSet) Pops(size int) []int

Pops randomly pops <size> items from set.

func (*IntSet) RLockFunc Uses

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

RLockFunc locks reading with callback function <f>.

func (*IntSet) Remove Uses

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

Remove deletes <item> from set.

func (*IntSet) Size Uses

func (set *IntSet) Size() int

Size returns the size of the set.

func (*IntSet) Slice Uses

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

Slice returns the a of items of the set as slice.

func (*IntSet) String Uses

func (set *IntSet) String() string

String returns items as a string, which are joined by char ','.

func (*IntSet) Sum Uses

func (set *IntSet) Sum() (sum int)

Sum sums items. Note: The items should be converted to int type, or you'd get a result that you unexpected.

func (*IntSet) Union Uses

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

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

type Set Uses

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

func New Uses

func New(unsafe ...bool) *Set

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 Uses

func NewFrom(items interface{}, unsafe ...bool) *Set

NewFrom returns a new set from <items>. Parameter <items> can be either a variable of any type, or a slice.

func NewSet Uses

func NewSet(unsafe ...bool) *Set

See New.

func (*Set) Add Uses

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

Add adds one or multiple items to the set.

func (*Set) Clear Uses

func (set *Set) Clear() *Set

Clear deletes all items of the set.

func (*Set) Complement Uses

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

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 Uses

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

Contains checks whether the set contains <item>.

func (*Set) Diff Uses

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

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

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

Equal checks whether the two sets equal.

func (*Set) Intersect Uses

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

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 Uses

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

IsSubsetOf checks whether the current set is a sub-set of <other>.

func (*Set) Iterator Uses

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

Iterator iterates the set with given callback function <f>, if <f> returns true then continue iterating; or false to stop.

func (*Set) Join Uses

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

Join joins items with a string <glue>.

func (*Set) LockFunc Uses

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

LockFunc locks writing with callback function <f>.

func (*Set) Merge Uses

func (set *Set) Merge(others ...*Set) *Set

Merge adds items from <others> sets into <set>.

func (*Set) Pop Uses

func (set *Set) Pop(size int) interface{}

Pops randomly pops an item from set.

func (*Set) Pops Uses

func (set *Set) Pops(size int) []interface{}

Pops randomly pops <size> items from set.

func (*Set) RLockFunc Uses

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

RLockFunc locks reading with callback function <f>.

func (*Set) Remove Uses

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

Remove deletes <item> from set.

func (*Set) Size Uses

func (set *Set) Size() int

Size returns the size of the set.

func (*Set) Slice Uses

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

Slice returns the a of items of the set as slice.

func (*Set) String Uses

func (set *Set) String() string

String returns items as a string, which are joined by char ','.

func (*Set) Sum Uses

func (set *Set) Sum() (sum int)

Sum sums items. Note: The items should be converted to int type, or you'd get a result that you unexpected.

func (*Set) Union Uses

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

Union returns a new set which is the union of <set> and <others>. Which means, all the items in <newSet> are in <set> or in <others>.

type StringSet Uses

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

func NewStringSet Uses

func NewStringSet(unsafe ...bool) *StringSet

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

func NewStringSetFrom(items []string, unsafe ...bool) *StringSet

NewStringSetFrom returns a new set from <items>.

func (*StringSet) Add Uses

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

Add adds one or multiple items to the set.

func (*StringSet) Clear Uses

func (set *StringSet) Clear() *StringSet

Clear deletes all items of the set.

func (*StringSet) Complement Uses

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

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 (*StringSet) Contains Uses

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

Contains checks whether the set contains <item>.

func (*StringSet) Diff Uses

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

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 (*StringSet) Equal Uses

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

Equal checks whether the two sets equal.

func (*StringSet) Intersect Uses

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

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 (*StringSet) IsSubsetOf Uses

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

IsSubsetOf checks whether the current set is a sub-set of <other>.

func (*StringSet) Iterator Uses

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

Iterator iterates the set with given callback function <f>, if <f> returns true then continue iterating; or false to stop.

func (*StringSet) Join Uses

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

Join joins items with a string <glue>.

func (*StringSet) LockFunc Uses

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

LockFunc locks writing with callback function <f>.

func (*StringSet) Merge Uses

func (set *StringSet) Merge(others ...*StringSet) *StringSet

Merge adds items from <others> sets into <set>.

func (*StringSet) Pop Uses

func (set *StringSet) Pop(size int) string

Pops randomly pops an item from set.

func (*StringSet) Pops Uses

func (set *StringSet) Pops(size int) []string

Pops randomly pops <size> items from set.

func (*StringSet) RLockFunc Uses

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

RLockFunc locks reading with callback function <f>.

func (*StringSet) Remove Uses

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

Remove deletes <item> from set.

func (*StringSet) Size Uses

func (set *StringSet) Size() int

Size returns the size of the set.

func (*StringSet) Slice Uses

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

Slice returns the a of items of the set as slice.

func (*StringSet) String Uses

func (set *StringSet) String() string

String returns items as a string, which are joined by char ','.

func (*StringSet) Sum Uses

func (set *StringSet) Sum() (sum int)

Sum sums items. Note: The items should be converted to int type, or you'd get a result that you unexpected.

func (*StringSet) Union Uses

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

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

Package gset imports 3 packages (graph) and is imported by 5 packages. Updated 2019-07-18. Refresh now. Tools for package owners.