set

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set is a set of elements based on hash table

func Diff added in v1.2.9

func Diff(sets ...*Set) *Set

Diff subtracts two sets

func Intersect added in v1.2.9

func Intersect(sets ...*Set) *Set

Intersect intersects two sets

func Make

func Make(members ...string) *Set

Make creates a new set

func Union added in v1.2.9

func Union(sets ...*Set) *Set

Union adds two sets

func (*Set) Add

func (set *Set) Add(val string) int

Add adds member into set

func (*Set) ForEach

func (set *Set) ForEach(consumer func(member string) bool)

ForEach visits each member in the set

func (*Set) Has

func (set *Set) Has(val string) bool

Has returns true if the val exists in the set

func (*Set) Len

func (set *Set) Len() int

Len returns number of members in the set

func (*Set) RandomDistinctMembers

func (set *Set) RandomDistinctMembers(limit int) []string

RandomDistinctMembers randomly returns keys of the given number, won't contain duplicated key

func (*Set) RandomMembers

func (set *Set) RandomMembers(limit int) []string

RandomMembers randomly returns keys of the given number, may contain duplicated key

func (*Set) Remove

func (set *Set) Remove(val string) int

Remove removes member from set

func (*Set) ShallowCopy added in v1.2.9

func (set *Set) ShallowCopy() *Set

ShallowCopy copies all members to another set

func (*Set) ToSlice

func (set *Set) ToSlice() []string

ToSlice convert set to []string

Jump to

Keyboard shortcuts

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