Documentation
¶
Index ¶
- func SortedItems[T cmp.Ordered](s Set[T]) []T
- type Set
- func (s Set[T]) Clear()
- func (s Set[T]) Contains(item T) bool
- func (s Set[T]) Difference(s2 Set[T]) Set[T]
- func (s Set[T]) Insert(items ...T)
- func (s Set[T]) Intersect(s2 Set[T]) Set[T]
- func (s Set[T]) Iter() iter.Seq[T]
- func (s Set[T]) Range(cb func(T) bool)
- func (s Set[T]) Remove(item T) bool
- func (s Set[T]) Size() int
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) Union(s2 Set[T]) Set[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortedItems ¶
Types ¶
type Set ¶
type Set[T comparable] map[T]empty
func From ¶
func From[T comparable](items ...T) Set[T]
From creates a new set of one or more items of type T
func (Set[T]) Difference ¶
Difference returns a new set of type T containing only the items uncommon bewteen the two sets.
func (Set[T]) Insert ¶
func (s Set[T]) Insert(items ...T)
Insert adds one or more items of type T to the set.
func (Set[T]) Intersect ¶
Intersect returns a new set of type T containing only the items common between the two sets.
func (Set[T]) Range ¶
Range loops over the set and calls the provided callback. If the callback returns true, iteration continues. If the callback returns false, iteration stops.
func (Set[T]) Remove ¶
Remove removes an item of type T from the set and returns true if the item existed. Remove returns false if the item did not exist in the set.
Click to show internal directories.
Click to hide internal directories.