Documentation ¶
Index ¶
- type Set
- func (ids *Set[T]) Add(elts ...T)
- func (ids Set[T]) CappedList(size int) []T
- func (ids *Set[T]) Clear()
- func (ids *Set[T]) Contains(elt T) bool
- func (ids *Set[T]) Difference(set Set[T])
- func (ids Set[T]) Equals(other Set[T]) bool
- func (ids Set[T]) Len() int
- func (ids Set[T]) List() []T
- func (ids *Set[T]) MarshalJSON() ([]byte, error)
- func (ids *Set[T]) Overlaps(big Set[T]) bool
- func (ids *Set[T]) Peek() (T, bool)
- func (ids *Set[T]) Pop() (T, bool)
- func (ids *Set[T]) Remove(elts ...T)
- func (ids Set[T]) String() string
- func (ids *Set[T]) Union(set Set[T])
- type Settable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T Settable] map[T]struct{}
Set is a set of IDs
func NewSet ¶
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 (ids *Set[T]) Add(elts ...T)
Add all the ids to this set, if the id 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 ids from the provided set to this set.
func (*Set[T]) MarshalJSON ¶
func (*Set[T]) Pop ¶
Removes and returns an element. If the set is empty, does nothing and returns false.
func (*Set[T]) Remove ¶
func (ids *Set[T]) Remove(elts ...T)
Remove all the id from this set, if the id isn't in the set, nothing happens
type Settable ¶
type Settable interface { comparable String() string }
Settable describes an element that can be in a set.