sets

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 3 Imported by: 13

README

Go Reference Go Report Card GitHub Release Coverage

sets

Sets and Set operations in golang (ie map[T]struct{} but with helper functions/nicer names, hiding the struct{}{} etc...)

Documentation

Overview

Sets and Set type and operations in go 1.18+ generics. (pending built in support in golang core)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveCommon

func RemoveCommon[T comparable](a, b Set[T])

RemoveCommon removes elements from both sets that are in both, leaving only the delta. Useful for Notifier on Set so that oldValue has what has been removed and newValue has what has been added.

Types

type Set

type Set[T comparable] map[T]struct{}

func FromSlice

func FromSlice[T comparable](items []T) Set[T]

SetFromSlice constructs a Set from a slice.

func New

func New[T comparable](item ...T) Set[T]

func (Set[T]) Add

func (s Set[T]) Add(item ...T)

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

func (Set[T]) Has

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

func (Set[T]) Remove

func (s Set[T]) Remove(item ...T)

func (Set[T]) String

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

Jump to

Keyboard shortcuts

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