Documentation
¶
Overview ¶
(TOC) This package provides a generic unordered set implementation (using a map under the hood).
Index ¶
- type Set
- func (me *Set[E]) Add(elements ...E)
- func (me *Set[E]) All() iter.Seq[E]
- func (me *Set[E]) AllX(start ...int) iter.Seq2[int, E]
- func (me *Set[E]) Clear()
- func (me *Set[E]) Clone() Set[E]
- func (me *Set[E]) Contains(element E) bool
- func (me *Set[E]) Delete(elements ...E)
- func (me *Set[E]) Difference(other Set[E]) Set[E]
- func (me *Set[E]) Equal(other Set[E]) bool
- func (me *Set[E]) Intersection(other Set[E]) Set[E]
- func (me *Set[E]) IsDisjoint(other Set[E]) bool
- func (me *Set[E]) IsEmpty() bool
- func (me *Set[E]) IsSubsetOf(other Set[E]) bool
- func (me Set[E]) IsSupersetOf(other Set[E]) bool
- func (me *Set[E]) Len() int
- func (me *Set[E]) String() string
- func (me *Set[E]) SymmetricDifference(other Set[E]) Set[E]
- func (me *Set[E]) ToSlice() []E
- func (me *Set[E]) Union(other Set[E]) Set[E]
- func (me *Set[E]) Unite(other Set[E])
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[E comparable] struct { // contains filtered or unexported fields }
func New ¶
func New[E comparable](elements ...E) Set[E]
New returns a new Set containing the given elements (if any). If no elements are given, the type must be specified since it can't be inferred.
func (*Set[E]) Delete ¶
func (me *Set[E]) Delete(elements ...E)
Delete deletes the given element(s) from the Set.
func (*Set[E]) Difference ¶
Difference returns a new Set that contains the elements which are in this Set that are not in the other Set.
func (*Set[E]) Equal ¶
Equal returns true if this Set has the same elements as the other Set; otherwise returns false.
func (*Set[E]) Intersection ¶
Intersection returns a new Set that contains the elements this Set has in common with the other Set.
func (*Set[E]) IsDisjoint ¶
IsDisjoint returns true if this Set has no elements in common with the other Set; otherwise returns false.
func (*Set[E]) IsEmpty ¶ added in v1.0.1
IsEmpty returns true if there are no elements in the Set; otherwise returns false.
func (*Set[E]) IsSubsetOf ¶
IsSubsetOf returns true if this Set is a subset of the other Set, i.e., if every member of this Set is in the other Set; otherwise returns false.
func (Set[E]) IsSupersetOf ¶
IsSupersetOf returns true if this Set is a superset of the other Set, i.e., if every member of the other Set is in this Set; otherwise returns false.
func (*Set[E]) SymmetricDifference ¶
SymmetricDifference returns a new Set that contains the elements which are in this Set or the other Set—but not in both Sets.
func (*Set[E]) ToSlice ¶
func (me *Set[E]) ToSlice() []E
ToSlice returns this Set's elements as an unsorted slice. For iteration either use this, or if you only need one value at a time, use [All] or [AllX]. To sort, use slices.Sorted (if E is cmp.Orderable).