go.bigb.es/auxilia

v0.2.0
Doc Versions Source

Types

T type Set

src
type Set[T comparable] struct {
	// contains filtered or unexported fields
}

Set is a generic set backed by map[T]struct{}.

f func NewSet

src
func NewSet[T comparable](expectedSize int) Set[T]

NewSet creates an empty set with a capacity hint.

f func NewSetFromListFunc

src
func NewSetFromListFunc[I any, T comparable](inp []I, f func(I) T) Set[T]

NewSetFromListFunc creates a set by applying f to each element of inp.

m func (*Set[T]) Add

src
func (s *Set[T]) Add(key T) bool

Add inserts key into the set. It returns true if the key was newly added.

m func (Set[T]) Delete

src
func (s Set[T]) Delete(key T) bool

Delete removes key from the set. It returns true if the key existed.

m func (Set[T]) Has

src
func (s Set[T]) Has(key T) bool

Has reports whether key is in the set.

m func (Set[T]) Iterator

src
func (s Set[T]) Iterator() collect.ListIterator[T]

Iterator returns a collect.ListIterator over the set elements. The iteration order is not guaranteed.

m func (Set[T]) Len

src
func (s Set[T]) Len() int

Len returns the number of elements in the set.

Source Files