set

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 0 Imported by: 1

README

set

Go Report Card Documentation license

A simple set datastructure in Go, with generics!

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 represents a set of unique elements

func New

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

New returns a new set

func (Set[T]) Add

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

Add adds a list of elements to a set

func (Set[T]) Copy

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

Copy returns a copy of a set

func (Set[T]) Has

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

Has returns true if an element is in a set

func (Set[T]) Join

func (s Set[T]) Join(ss Set[T]) Set[T]

Join joins two sets

func (Set[T]) Remove

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

Remove removes a list of elements from a set

func (Set[T]) Slice

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

Slice returns the set as a slice

Jump to

Keyboard shortcuts

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