sets

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 1 Imported by: 4 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

Overview

Package sets implement a set type as a `map[T]struct{}` but with better ergonomics.

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 implements a Set for the key type T.

func Make

func Make[T comparable](size ...int) Set[T]

Make returns an empty Set of the given type. Size is optional, and if given will reserve the expected size.

func MakeWith

func MakeWith[T comparable](elements ...T) Set[T]

MakeWith creates a Set[T] with the given elements inserted.

func Union

func Union[T comparable](sets ...Set[T]) Set[T]

Union returns the union of all the given sets.

func (Set[T]) Equal

func (s Set[T]) Equal(s2 Set[T]) bool

Equal returns whether s and s2 have the exact same elements.

func (Set[T]) Has

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

Has returns true if Set s has the given key.

func (Set[T]) Insert

func (s Set[T]) Insert(keys ...T)

Insert keys into set.

func (Set[T]) Sub

func (s Set[T]) Sub(s2 Set[T]) Set[T]

Sub returns `s - s2`, that is, all elements in `s` that are not in `s2`.

Jump to

Keyboard shortcuts

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