Documentation ¶
Index ¶
- type Set
- func (s *Set[T]) Add(elts ...T)
- func (s Set[T]) CappedList(size int) []T
- func (s *Set[_]) Clear()
- func (s *Set[T]) Contains(elt T) bool
- func (s *Set[T]) Difference(set Set[T])
- func (s Set[T]) Equals(other Set[T]) bool
- func (s Set[_]) Len() int
- func (s Set[T]) List() []T
- func (s *Set[_]) MarshalJSON() ([]byte, error)
- func (s *Set[T]) Overlaps(big Set[T]) bool
- func (s *Set[T]) Peek() (T, bool)
- func (s *Set[T]) Pop() (T, bool)
- func (s *Set[T]) Remove(elts ...T)
- func (s *Set[T]) Union(set 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 set of elements.
func NewSet ¶
func NewSet[T comparable](size int) Set[T]
Return a new set with initial capacity [size]. More or less than [size] elements can be added to this set. Using NewSet() rather than Set[T]{} is just an optimization that can be used if you know how many elements will be put in this set.
func (*Set[T]) Add ¶
func (s *Set[T]) Add(elts ...T)
Add all the elements to this set. If the element is already in the set, nothing happens.
func (Set[T]) CappedList ¶
CappedList returns a list of length at most [size]. Size should be >= 0. If size < 0, returns nil.
func (*Set[T]) Difference ¶
Difference removes all the elements in set from [s].
func (*Set[_]) MarshalJSON ¶
func (*Set[T]) Pop ¶
Removes and returns an element. If the set is empty, does nothing and returns false.
Click to show internal directories.
Click to hide internal directories.