sets

package
v0.0.0-...-25a1aa9 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 1 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T comparable] map[T]struct{}

func New

func New[T comparable](items ...T) Set[T]

func (Set[T]) Add

func (s Set[T]) Add(items ...T) Set[T]

Add adds items to the set.

func (Set[T]) Equal

func (s Set[T]) Equal(set Set[T]) bool

Equal returns true if s is equal (as a set) to set.

func (Set[T]) Has

func (s Set[T]) Has(item T) bool

Has returns true if item is contained in the set.

func (Set[T]) HasAll

func (s Set[T]) HasAll(items ...T) bool

HasAll returns true if all items are contained in the set.

func (Set[T]) HasAny

func (s Set[T]) HasAny(items ...T) bool

HasAny returns true if any of the items are contained in the set.

func (Set[T]) Intersection

func (s Set[T]) Intersection(set Set[T]) Set[T]

Intersection returns a new set which includes the item in BOTH s1 and s2. For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}

func (Set[T]) Len

func (s Set[T]) Len() int

Len returns the size of the set.

func (Set[T]) List

func (s Set[T]) List() []T

List returns the contents as a string slice.

func (Set[T]) NotIn

func (s Set[T]) NotIn(set Set[T]) Set[T]

NotIn returns a set of objects that are not in the current set. For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.NotIn(s2) = {a3} s2.NotIn(s1) = {a4, a5}

func (Set[T]) Remove

func (s Set[T]) Remove(items ...T) Set[T]

Remove removes all items from the set.

func (Set[T]) Union

func (s Set[T]) Union(set Set[T]) Set[T]

Union returns a new set which includes items in either s1 or s2. For example: s1 = {a1, a2} s2 = {a3, a4} s1.Union(s2) = {a1, a2, a3, a4} s2.Union(s1) = {a1, a2, a3, a4}

type String

type String map[string]struct{}

func NewString

func NewString(items ...string) String

NewString creates a string set from a list of values.

func (String) Add

func (s String) Add(items ...string) String

Add adds items to the set.

func (String) Equal

func (s String) Equal(set String) bool

Equal returns true if s is equal (as a set) to set.

func (String) Has

func (s String) Has(item string) bool

Has returns true if item is contained in the set.

func (String) HasAll

func (s String) HasAll(items ...string) bool

HasAll returns true if all items are contained in the set.

func (String) HasAny

func (s String) HasAny(items ...string) bool

HasAny returns true if any of the items are contained in the set.

func (String) Intersection

func (s String) Intersection(set String) String

Intersection returns a new set which includes the item in BOTH s1 and s2. For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}

func (String) Len

func (s String) Len() int

Len returns the size of the set.

func (String) List

func (s String) List() []string

List returns the contents as a string slice.

func (String) NotIn

func (s String) NotIn(set String) String

NotIn returns a set of objects that are not in the current set. For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.NotIn(s2) = {a3} s2.NotIn(s1) = {a4, a5}

func (String) Remove

func (s String) Remove(items ...string) String

Remove removes all items from the set.

func (String) SortedList

func (s String) SortedList() []string

SortedList returns the contents as a sorted string slice.

func (String) Union

func (s String) Union(set String) String

Union returns a new set which includes items in either s1 or s2. For example: s1 = {a1, a2} s2 = {a3, a4} s1.Union(s2) = {a1, a2, a3, a4} s2.Union(s1) = {a1, a2, a3, a4}

Jump to

Keyboard shortcuts

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