gen

package
v0.0.0-...-004d278 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package set is a template Set type

Tries to be similar to Python's set type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

Set provides a general purpose set modeled on Python's set type.

func NewSizedStringSet

func NewSizedStringSet(capacity int) *StringSet

NewSizedSet returns a new empty set with the given capacity

func NewStringSet

func NewStringSet() *StringSet

NewSet returns a new empty set

func (*StringSet) Add

func (s *StringSet) Add(elem string) *StringSet

Add adds elem to the set, returning the set

If the element already exists then it has no effect

func (*StringSet) AddList

func (s *StringSet) AddList(elems []string) *StringSet

AddList adds a list of elems to the set

If the elements already exists then it has no effect

func (*StringSet) AsList

func (s *StringSet) AsList() []string

AsList returns all the elements as a slice

func (*StringSet) Clear

func (s *StringSet) Clear() *StringSet

Clear removes all the elements

func (*StringSet) Contains

func (s *StringSet) Contains(elem string) bool

Contains returns whether elem is in the set or not

func (*StringSet) Copy

func (s *StringSet) Copy() *StringSet

Copy returns a shallow copy of the Set

func (*StringSet) Difference

func (s *StringSet) Difference(other *StringSet) *StringSet

Difference returns a new set with all the elements that are in this set but not in the other

func (*StringSet) DifferenceUpdate

func (s *StringSet) DifferenceUpdate(other *StringSet) *StringSet

DifferenceUpdate removes all the elements that are in the other set from this set. It returns the set.

func (*StringSet) Discard

func (s *StringSet) Discard(elem string) *StringSet

Discard removes elem from the set

If it wasn't in the set it does nothing

It returns the set

func (*StringSet) Intersection

func (s *StringSet) Intersection(other *StringSet) *StringSet

Intersection returns a new set with all the elements that are only in this set and the other set. It returns the new set.

func (*StringSet) IntersectionUpdate

func (s *StringSet) IntersectionUpdate(other *StringSet) *StringSet

IntersectionUpdate changes this set so that it only contains elements that are in both this set and the other set. It returns the set.

func (*StringSet) IsDisjoint

func (s *StringSet) IsDisjoint(other *StringSet) bool

IsDisjoint returns a bool indicating whether this set and other set have no elements in common.

func (*StringSet) IsSubset

func (s *StringSet) IsSubset(strict bool, other *StringSet) bool

IsSubset returns a bool indicating whether this set is a subset of other set.

func (*StringSet) IsSuperset

func (s *StringSet) IsSuperset(strict bool, other *StringSet) bool

IsSuperset returns a bool indicating whether this set is a superset of other set.

func (*StringSet) Len

func (s *StringSet) Len() int

Len returns the number of elements in the set

func (*StringSet) Pop

func (s *StringSet) Pop(elem string) (string, bool)

Pop removes elem from the set and returns it

It also returns whether the elem was found or not

func (*StringSet) Remove

func (s *StringSet) Remove(elem string) bool

Remove removes elem from the set

It returns whether the elem was in the set or not

func (*StringSet) SymmetricDifference

func (s *StringSet) SymmetricDifference(other *StringSet) *StringSet

SymmetricDifference returns a new set of all elements that are a member of exactly one of this set and other set(elements which are in one of the sets, but not in both).

func (*StringSet) SymmetricDifferenceUpdate

func (s *StringSet) SymmetricDifferenceUpdate(other *StringSet) *StringSet

SymmetricDifferenceUpdate modifies this set to be a set of all elements that are a member of exactly one of this set and other set(elements which are in one of the sets, but not in both) and returns this set.

func (*StringSet) Union

func (s *StringSet) Union(other *StringSet) *StringSet

Union returns a new set with all the elements that are in either set. It returns the new set.

func (*StringSet) Update

func (s *StringSet) Update(other *StringSet) *StringSet

Update adds all the elements from the other set to this set. It returns the set.

type StringSetNothing

type StringSetNothing struct{}

SetNothing is used as a zero sized member in the map

Jump to

Keyboard shortcuts

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