sets

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 2 Imported by: 6

Documentation

Overview

Package sets provides generic sets.

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 convenience wrapper around map[T]struct{}.

func (Set[T]) Add

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

Add inserts the given elements to s and returns s.

func (Set[T]) AddSet

func (s Set[T]) AddSet(t Set[T]) Set[T]

AddSet inserts the elements of t to s and returns s.

func (Set[T]) Has

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

Has returns whether t is a member of s.

func (Set[T]) Intersect

func (s Set[T]) Intersect(t Set[T]) Set[T]

Intersect returns a new set holding the elements that are common to s and t.

func (Set[T]) MarshalJSON added in v0.1.13

func (s Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Set[T]) Remove

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

Remove deletes the given elements from s and returns s.

func (Set[T]) RemoveSet

func (s Set[T]) RemoveSet(t Set[T]) Set[T]

RemoveSet deletes the elements of t from s and returns s.

func (*Set[T]) UnmarshalJSON added in v0.1.13

func (s *Set[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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