set

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: GPL-3.0 Imports: 2 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

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

Diff subtracts two sets

func Intersect

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

Intersect intersects two sets

func Make

func Make(members ...string) *Set

Make creates a new set

func Union

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) SetScan

func (set *Set) SetScan(cursor int, count int, pattern string) ([][]byte, int)

Scan set with cursor and pattern

func (*Set) ShallowCopy

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