stringset

package
v0.0.0-...-83c1928 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidType = errors.New("invalid type")

ErrInvalidType is returned by initialization functions expecting specific types.

Functions

This section is empty.

Types

type StringSet

type StringSet map[string]struct{}

StringSet is an unordered set of unique strings.

func FromMapKeys

func FromMapKeys(m interface{}) (StringSet, error)

FromMapKeys returns a new StringSet initialized with m's keys. It returns InvalidType if m is not a map or its keys are not type string.

func FromMapVals

func FromMapVals(m interface{}) (StringSet, error)

FromMapVals returns a new StringSet initialized with m's values. It returns InvalidType if m is not a map or its values are not type string.

func FromSlice

func FromSlice(sl interface{}) (StringSet, error)

FromSlice returns a new StringSet initialized with s's values. It returns InvalidType if sl is not a slice of type string.

func New

func New(vals ...string) StringSet

New returns a new StringSet initialized with vals.

func (StringSet) Add

func (s StringSet) Add(val string)

Add adds val to the set if it does not already exist.

func (StringSet) Equals

func (s StringSet) Equals(t StringSet) bool

Equals returns true if all the values of s are in t and vice-versa. Order is not considered.

func (StringSet) Has

func (s StringSet) Has(val string) bool

Has returns true if val is in the set.

func (StringSet) Len

func (s StringSet) Len() int

Len returns the length of the set.

func (StringSet) Remove

func (s StringSet) Remove(val string)

Remove deletes val from the set if it exists.

func (StringSet) Slice

func (s StringSet) Slice() []string

Slice returns a slice with the values of the set in an arbitrary order.

func (StringSet) Sorted

func (s StringSet) Sorted() []string

Sorted returns a slice with the values of the set sorted.

func (StringSet) String

func (s StringSet) String() string

Jump to

Keyboard shortcuts

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