set

package
v0.0.0-...-78bf94d Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max

func Max(ss ...Set) (max int)

Max returns the size of the largest set.

func Min

func Min(ss ...Set) (min int)

Min returns the size of the smallest set.

Types

type Set

type Set map[string]struct{}

Set implements basic string set operations, not thread-safe.

func Filter

func Filter(s Set, f func(string) bool) Set

Filter returns a set containing all elements, which satisfy a given predicate.

func FromSlice

func FromSlice(vs []string) Set

FromSlice initializes a set from a slice.

func New

func New() Set

New creates a new set.

func (Set) Add

func (s Set) Add(v string) Set

Add adds an element.

func (Set) Clear

func (s Set) Clear()

Clear removes all elements.

func (Set) Contains

func (s Set) Contains(v string) bool

Contains returns membership status.

func (Set) Difference

func (s Set) Difference(t Set) Set

func (Set) Equals

func (s Set) Equals(t Set) bool

Equals returns true, if sets contain the same elements.

func (Set) Intersection

func (s Set) Intersection(t Set) Set

Intersection returns a new set containing all elements found in both sets.

func (Set) IsEmpty

func (s Set) IsEmpty() bool

IsEmpty returns if set has zero elements.

func (Set) Jaccard

func (s Set) Jaccard(t Set) float64

Jaccard returns the jaccard index of sets s and t, between 0 and 1, where 1 means equality.

func (Set) Join

func (s Set) Join(sep string) string

Join joins elements from a set with given separator.

func (Set) Len

func (s Set) Len() int

Len returns number of elements in set.

func (Set) Product

func (s Set) Product(t Set) (result [][]string)

Product returns a slice of pairs, representing the cartesian product of two sets.

func (Set) Slice

func (s Set) Slice() (result []string)

Slice returns all elements as a slice.

func (Set) Sorted

func (s Set) Sorted() (result []string)

Sorted returns all elements as a slice, sorted.

func (Set) TopK

func (s Set) TopK(k int) Set

TopK returns at most k sorted elements.

func (Set) Union

func (s Set) Union(t Set) Set

Union returns the union of two sets.

Jump to

Keyboard shortcuts

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