set
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package set contains set types.
Index¶
- type Handle
- type HandleSet
- type IntSet
- func (s *IntSet[T]) Add(e T)
- func (s *IntSet[T]) AddSeq(seq iter.Seq[T])
- func (s IntSet[T]) Clone() IntSet[T]
- func (s IntSet[T]) Contains(e T) bool
- func (s *IntSet[T]) Delete(e T)
- func (s *IntSet[T]) DeleteSeq(seq iter.Seq[T])
- func (s IntSet[T]) Equal(other IntSet[T]) bool
- func (s IntSet[T]) Len() int
- func (s IntSet[T]) Values() iter.Seq[T]
- type Set
- func (s Set[T]) Add(e T)
- func (s Set[T]) AddSet(es Set[T])
- func (s Set[T]) AddSlice(es []T)
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Contains(e T) bool
- func (s Set[T]) Delete(e T)
- func (s Set[T]) Equal(other Set[T]) bool
- func (s Set[T]) Len() int
- func (s *Set[T]) Make()
- func (s Set[T]) MarshalJSON() ([]byte, error)
- func (s Set[T]) Slice() []T
- func (s *Set[T]) UnmarshalJSON(buf []byte) error
- type Slice
- type SmallSet
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeHandle¶
type Handle struct {// contains filtered or unexported fields}Handle is an opaque comparable value that's used as the map key in aHandleSet.
typeHandleSet¶
HandleSet is a set of T.
It is not safe for concurrent use.
func (*HandleSet[T])Add¶
Add adds the element (map value) e to the set.
It returns a new handle (map key) with which e can be removed, using a mapdelete or theHandleSet.Delete method.
typeIntSet¶added inv1.86.0
type IntSet[Tconstraints.Integer] struct {// contains filtered or unexported fields}
IntSet is a set optimized for integer values close to zeroor set of integers that are close in value.
funcIntsOf¶added inv1.88.0
func IntsOf[Tconstraints.Integer](slice ...T)IntSet[T]
IntsOf constructs anIntSet with the provided elements.
func (*IntSet[T])Add¶added inv1.86.0
func (s *IntSet[T]) Add(e T)
Add adds e to the set.
When storing a IntSet in a map as a value type,it is important to re-assign the map entry after calling Add or Delete,as the IntSet's representation may change.
func (*IntSet[T])Delete¶added inv1.86.0
func (s *IntSet[T]) Delete(e T)
Delete removes e from the set.
When storing a IntSet in a map as a value type,it is important to re-assign the map entry after calling Add or Delete,as the IntSet's representation may change.
typeSet¶added inv1.42.0
type Set[Tcomparable] map[T]struct{}
Set is a set of T.
funcOf¶added inv1.66.0
func Of[Tcomparable](slice ...T)Set[T]
Of returns a new set constructed from the elements in slice.
funcSetOf¶added inv1.52.0
func SetOf[Tcomparable](slice []T)Set[T]
SetOf returns a new set constructed from the elements in slice.
func (Set[T])AddSlice¶added inv1.52.0
func (sSet[T]) AddSlice(es []T)
AddSlice adds each element of es to s.
func (*Set[T])Make¶added inv1.66.0
func (s *Set[T]) Make()
Make lazily initializes the map pointed to by s to be non-nil.
func (Set[T])MarshalJSON¶added inv1.56.0
func (Set[T])Slice¶added inv1.52.0
func (sSet[T]) Slice() []T
Slice returns the elements of the set as a slice. The elements will not bein any particular order.
func (*Set[T])UnmarshalJSON¶added inv1.56.0
typeSlice¶added inv1.40.0
type Slice[Tcomparable] struct {// contains filtered or unexported fields}
Slice is a set of elements tracked in a slice of unique elements.
func (*Slice[T])Add¶added inv1.40.0
func (ss *Slice[T]) Add(vs ...T)
Add adds each element in vs to the set.The amortized cost is O(1) per element.
func (*Slice[T])Contains¶added inv1.40.0
Contains reports whether v is in the set.The amortized cost is O(1).
typeSmallSet¶added inv1.86.0
type SmallSet[Tcomparable] struct {// contains filtered or unexported fields}
SmallSet is a set that is optimized for reducing memory overhead when theexpected size of the set is 0 or 1 elements.
The zero value of SmallSet is a usable empty set.
When storing a SmallSet in a map as a value type, it is important to re-assignthe map entry after calling Add or Delete, as the SmallSet's representationmay change.
Copying a SmallSet by value may alias the previous value. Use the Clone methodto create a new SmallSet with the same contents.
func (*SmallSet[T])Add¶added inv1.86.0
func (s *SmallSet[T]) Add(e T)
Add adds e to the set.
When storing a SmallSet in a map as a value type, it is important tore-assign the map entry after calling Add or Delete, as the SmallSet'srepresentation may change.
func (*SmallSet[T])Delete¶added inv1.86.0
func (s *SmallSet[T]) Delete(e T)
Delete removes e from the set.
When storing a SmallSet in a map as a value type, it is important tore-assign the map entry after calling Add or Delete, as the SmallSet'srepresentation may change.
func (SmallSet[T])SoleElement¶added inv1.86.0
SoleElement returns the single value in the set, if the set has exactly oneelement.
If the set is empty or has more than one element, ok will be false and e willbe the zero value of T.