set

package
v2.10.52 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set represents a set. It is implemented as a thin wrapper over a map with a zero sized value.

func FromValues

func FromValues[T comparable](values []T) Set[T]

FromValues creates a new set from the given values. If the provided values contain duplicates, the set will only contain one of instance of each value.

func WithCapacity

func WithCapacity[T comparable](cap int) Set[T]

WithCapacity creates a new set with the given capacity.

func (*Set[T]) Add

func (s *Set[T]) Add(value T) bool

Add adds the given value to the set. Returns true, iff the value was not part of the set and was actually added.

func (*Set[T]) Contains

func (s *Set[T]) Contains(value T) bool

Contains returns true iff the value is part of the Set.

func (*Set[T]) Len

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

Len returns the number of values in the Set.

func (*Set[T]) Remove

func (s *Set[T]) Remove(value T) bool

Remove removes the given value from the set. Returns true, iff the value was part of the set and got removed.

Jump to

Keyboard shortcuts

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