Documentation
¶
Overview ¶
Package set implements a simple generic, not threadsafe set data structure. It provides constructors form slices and maps, and methods for typical set operations.
Index ¶
- type Set
- func (set Set[T]) Add(s T)
- func (set Set[T]) AddAll(slice []T)
- func (set Set[T]) Contains(s T) bool
- func (set Set[T]) Difference(other Set[T]) Set[T]
- func (set Set[T]) Equals(other Set[T]) bool
- func (set Set[T]) Intersection(other Set[T]) Set[T]
- func (set Set[T]) IsProperSubsetOf(other Set[T]) bool
- func (set Set[T]) IsSubsetOf(other Set[T]) bool
- func (set Set[T]) Remove(s T)
- func (set Set[T]) RemoveAll(slice []T)
- func (set Set[T]) ToSlice() []T
- func (set Set[T]) Union(other Set[T]) Set[T]
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 generic, not threadsafe set data structure.
func NewFromMapKeys ¶
func NewFromMapKeys[T comparable, V any](m map[T]V) Set[T]
NewFromMapKeys creates a new Set from a map's keys.
func NewFromSlice ¶
func NewFromSlice[T comparable](slice []T) Set[T]
NewFromSlice creates a new Set from a slice of comparable.
func (Set[T]) AddAll ¶
func (set Set[T]) AddAll(slice []T)
AddAll adds a slice of elements to a Set.
func (Set[T]) Difference ¶
Difference returns the difference of two Sets as new Set.
func (Set[T]) Intersection ¶
Intersection returns the intersection of two Sets as new Set.
func (Set[T]) IsProperSubsetOf ¶
IsProperSubsetOf returns true if a Set is a proper subset of another Set (they cannot be equal).
func (Set[T]) IsSubsetOf ¶
IsSubsetOf returns true if a Set is a subset of another Set (they can be equal).
func (Set[T]) RemoveAll ¶
func (set Set[T]) RemoveAll(slice []T)
RemoveAll removes a slice of elements from a Set.