Documentation ¶
Overview ¶
Package set contains set types.
Index ¶
- type Handle
- type HandleSet
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle is an opaque comparable value that's used as the map key in a HandleSet. The only way to get one is to call HandleSet.Add.
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a set of T.
func Of ¶
func Of[T comparable](slice ...T) Set[T]
Of returns a new set constructed from the elements in slice.
func SetOf ¶
func SetOf[T comparable](slice []T) Set[T]
SetOf returns a new set constructed from the elements in slice.
func (*Set[T]) Make ¶
func (s *Set[T]) Make()
Make lazily initializes the map pointed to by s to be non-nil.
func (Set[T]) MarshalJSON ¶
func (Set[T]) Slice ¶
func (s Set[T]) Slice() []T
Slice returns the elements of the set as a slice. The elements will not be in any particular order.
func (*Set[T]) UnmarshalJSON ¶
type Slice ¶
type Slice[T comparable] struct { // contains filtered or unexported fields }
Slice is a set of elements tracked in a slice of unique elements.
func (*Slice[T]) Add ¶
func (ss *Slice[T]) Add(vs ...T)
Add adds each element in vs to the set. The amortized cost is O(1) per element.
Click to show internal directories.
Click to hide internal directories.