collections

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MPL-2.0 Imports: 4 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] map[T]struct{}

Set is a container that can hold each item only once and has a fast lookup time.

You can define a new set like this:

var validKeyLengths = collections.Set[int]{
    16: {},
    24: {},
    32: {},
}

You can also use the constructor to create a new set

var validKeyLengths = collections.NewSet[int](16,24,32)

func CollectSet

func CollectSet[T comparable](seq iter.Seq[T]) Set[T]

CollectSet returns a new set containing all of the distinct values from the given sequence.

func NewSet

func NewSet[T comparable](members ...T) Set[T]

Constructs a new set given the members of type T

func (Set[T]) Has

func (s Set[T]) Has(value T) bool

Has returns true if the item exists in the Set

func (Set[T]) Intersection added in v0.21.0

func (s Set[T]) Intersection(other Set[T]) Set[T]

Intersection returns the common items between the receiver and the given sets.

func (Set[T]) String

func (s Set[T]) String() string

String creates a comma-separated list of all values in the set.

Jump to

Keyboard shortcuts

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