Documentation
¶
Index ¶
- type Set
- func (s Set[T]) Add(k T)
- func (s Set[T]) Copy() Set[T]
- func (s Set[T]) Del(k T)
- func (s Set[T]) Eq(s2 Set[T]) bool
- func (s Set[T]) Filter(p func(k T) bool) Set[T]
- func (s Set[T]) FilterInPlace(p func(k T) bool)
- func (s Set[T]) Has(k T) bool
- func (s Set[T]) IntersectWith(s2 Set[T])
- func (s Set[T]) Iterate(f func(k T))
- func (s Set[T]) Len() int
- func (s Set[T]) MinusWith(s2 Set[T])
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) UnionWith(s2 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{}
func FromMapKey ¶
func FromMapKey[K comparable, V any](m map[K]V) Set[K]
FromMapKey returns a Set of type T with all keys from the given map.
func FromSlice ¶
func FromSlice[T comparable](a []T) Set[T]
FromSlice returns a Set of type T with all elements from the given slice.
func Intersect ¶
func Intersect[T comparable](s1, s2 Set[T]) Set[T]
Intersect returns a Set of type T with elements that exists in both of the given sets.
func Minus ¶
func Minus[T comparable](s1, s2 Set[T]) Set[T]
Minus returns a Set of type T with elements that exists in the first but not the second given set.
func Union ¶
func Union[T comparable](s1, s2 Set[T]) Set[T]
Union returns a Set of type T with elements that exists in either of the given sets.
func (Set[T]) Filter ¶
Filter filters the set by the given predicament and adds them to a new set for return.
func (Set[T]) FilterInPlace ¶
FilterInPlace filters the set by the given predicament and acts in-place.
func (Set[T]) IntersectWith ¶
IntersectWith removes all elements from the current set if it's not in the given set.
func (Set[T]) Iterate ¶
func (s Set[T]) Iterate(f func(k T))
Iterate iterates the set by calling the given function with each element in the set.