Documentation
¶
Overview ¶
ds contains data structure implementations that can be reused across other modules.
Index ¶
- type Set
- func (s Set[T]) Add(elements ...T)
- func (s Set[T]) Difference(o Set[T]) Set[T]
- func (s Set[T]) Empty() bool
- func (s Set[T]) Equal(o Set[T]) bool
- func (s Set[T]) Has(element T) bool
- func (s Set[T]) Intersection(o Set[T]) Set[T]
- func (s Set[T]) Remove(element T)
- func (s Set[T]) Size() int
- func (s Set[T]) SymmetricDifference(o Set[T]) Set[T]
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) ToSortedSlice(cmp func(a T, b T) int) []T
- func (s Set[T]) Union(o 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]bool
Set is a generic set type.
func NewSet ¶
func NewSet[T comparable](elements ...T) Set[T]
func SetDifference ¶
func SetDifference[T comparable](a, b []T) Set[T]
SetDifference (a-b) returns the set of elements that are in a, but not b.
func (Set[T]) Difference ¶
Difference (s-o) returns elements that are in the receiver set, but not the given set 'o'.
func (Set[T]) Intersection ¶
Intersection (s∩o) returns elements that are in both sets.
func (Set[T]) SymmetricDifference ¶
SymmetricDifference (s-o)∪(o-s) returns elements that are in the receiver set, but not the given set 'o', along with those that are in 'o', but not the receiver set.
func (Set[T]) ToSlice ¶
func (s Set[T]) ToSlice() []T
ToSlice returns a slice of all the elements in the set.
func (Set[T]) ToSortedSlice ¶
ToSortedSlice returns a sorted slice of all the elements in the set.
Click to show internal directories.
Click to hide internal directories.