set

package
v0.0.0-...-0212348 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 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 Make

func Make(members ...string) *Set

Make creates a new set

func (*Set) Add

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

Add adds member into set

func (*Set) Diff

func (set *Set) Diff(another *Set) *Set

Diff subtracts two sets

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

func (set *Set) Intersect(another *Set) *Set

Intersect intersects two sets

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

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

ToSlice convert set to []string

func (*Set) Union

func (set *Set) Union(another *Set) *Set

Union adds two sets

Jump to

Keyboard shortcuts

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