Documentation
¶
Overview ¶
Package set defines a set type, a mutable, unordered collection of unique elements, analogous to Python's set collection, as well as functions to perform typical mathematical set operations.
The underlying type of this set implementation is a map. This means that all operations that can be done with maps can also be done with sets.
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{}
Set is a map where the key type is generic and all values are empty structs that take up no space in memory.
func NewSet ¶
func NewSet[T comparable](items ...T) Set[T]
NewSet takes a variable number of arguments and returns a set containing those values.
func (*Set[T]) Contains ¶
Contains returns true if the given value is found in the set. Otherwise, returns false.
func (*Set[T]) Elements ¶
func (set *Set[T]) Elements() []T
Elements returns a slice containing all members of the set.