Skip to content

set

Go
import "github.com/andreoliwa/logseq-doctor/pkg/set"

Index

type Set

Set is a simple implementation of a set using a map.

Go
type Set[T cmp.Ordered] struct {
    data map[T]struct{}
}

func NewSet

Go
func NewSet[T cmp.Ordered]() *Set[T]

NewSet creates and returns a new set.

func (*Set[T]) Add

Go
func (s *Set[T]) Add(value T)

Add inserts an element into the set.

func (*Set[T]) Clear

Go
func (s *Set[T]) Clear()

Clear removes all elements from the set.

func (*Set[T]) Contains

Go
func (s *Set[T]) Contains(value T) bool

Contains checks if an element exists in the set.

func (*Set[T]) Diff

Go
func (s *Set[T]) Diff(sets ...*Set[T]) *Set[T]

Diff returns a new set containing elements that are in the current set but not in the provided sets.

func (*Set[T]) Remove

Go
func (s *Set[T]) Remove(value T)

Remove deletes an element from the set.

func (*Set[T]) Size

Go
func (s *Set[T]) Size() int

Size returns the number of elements in the set.

func (*Set[T]) Update

Go
func (s *Set[T]) Update(sets ...*Set[T])

Update adds all elements from the given sets into the current set.

func (*Set[T]) Values

Go
func (s *Set[T]) Values() []T

Values returns all elements in the set as a slice.

func (*Set[T]) ValuesSorted

Go
func (s *Set[T]) ValuesSorted() []T

ValuesSorted returns all elements in the set as a sorted slice.

Generated by gomarkdoc