set

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Unordered

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

func Collect

func Collect[E comparable](seq iter.Seq[E]) (res Unordered[E])

Collect collects values from seq into a new `Unordered` set.

func NewUnordered

func NewUnordered[T comparable](el ...T) (s Unordered[T])

NewUnordered constructs an `Unordered` set from elements. The capacity is set to `2*len(el)`.

func NewUnorderedWithCap

func NewUnorderedWithCap[T comparable](capacity int, el ...T) (s Unordered[T])

NewUnorderedWithCap constructs an `Unordered` set from elements and sets the capacity.

func (*Unordered[T]) Equal

func (s *Unordered[T]) Equal(other *Unordered[T]) bool

Equal tests if two sets are identical.

func (*Unordered[T]) Exists

func (s *Unordered[T]) Exists(e T) bool

Exists checks if `e` is already in the set.

func (*Unordered[T]) Insert

func (s *Unordered[T]) Insert(e T) bool

Insert inserts an element into the set and returns `true` if it existed already.

func (*Unordered[T]) Keys

func (s *Unordered[T]) Keys() iter.Seq[T]

Keys returns the same as `Values`.

func (*Unordered[T]) Len

func (s *Unordered[T]) Len() int

Len returns the length of the set.

func (Unordered[T]) LogValue

func (s Unordered[T]) LogValue() slog.Value

LogValue implements slog.LogValuer for structured logging.

func (*Unordered[T]) Remove

func (s *Unordered[T]) Remove(e T) bool

Removes an element `e` from the set and returns `true` if it was removed.

func (*Unordered[T]) String

func (s *Unordered[T]) String() string

String returns the conversion to a string.

func (*Unordered[T]) Values

func (s *Unordered[T]) Values() iter.Seq[T]

Values returns an iterator over values in m. The iteration order is not specified and is not guaranteed to be the same from one call to the next.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL