Documentation
¶
Index ¶
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 defines a set of comparable values.
func From ¶
func From[T comparable](collection []T) Set[T]
From creates a Set from the given collection.
func FromSeq ¶
func FromSeq[T comparable](seq iter.Seq[T]) Set[T]
FromSeq creates a Set from the given iterator.
type SetLike ¶
type SetLike[T comparable] interface { fmt.Stringer // Len returns the number of elements in the Set. Len() int // Values returns an iterator over the Set values. Values() iter.Seq[T] // ToSlice converts the Set to a slice. ToSlice() []T // Contains checks if the Set contains the given value. Contains(value T) bool // Insert adds the given value to the Set. Insert(value T) // Delete removes the given value from the Set. Delete(value T) // contains filtered or unexported methods }
type StableSet ¶
type StableSet[T comparable] struct { // contains filtered or unexported fields }
StableSet defines a set of comparable values that maintains insertion order.
func FromSeqStable ¶
func FromSeqStable[T comparable](seq iter.Seq[T]) *StableSet[T]
FromSeqStable creates a Set from the given iterator.
func FromStable ¶
func FromStable[T comparable](collection []T) *StableSet[T]
FromStable creates a StableSet from the given collection.
func NewStable ¶
func NewStable[T comparable](values ...T) *StableSet[T]
NewStable creates a new StableSet from the given values.
func (*StableSet[T]) Delete ¶
func (s *StableSet[T]) Delete(value T)
Delete removes the given value from the Set.
func (*StableSet[T]) Insert ¶
func (s *StableSet[T]) Insert(value T)
Insert adds the given value to the Set.
Click to show internal directories.
Click to hide internal directories.