ds

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: PostgreSQL Imports: 1 Imported by: 0

Documentation

Overview

ds contains data structure implementations that can be reused across other modules.

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]bool

Set is a generic set type.

func NewSet

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

func SetDifference

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

SetDifference (a-b) returns the set of elements that are in a, but not b.

func (Set[T]) Add

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

Add adds an element to the set.

func (Set[T]) Difference

func (s Set[T]) Difference(o Set[T]) Set[T]

Difference (s-o) returns elements that are in the receiver set, but not the given set 'o'.

func (Set[T]) Empty

func (s Set[T]) Empty() bool

Empty returns whether the set is empty.

func (Set[T]) Equal

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

Equal returns whether the given set is equal to the receiver set.

func (Set[T]) Has

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

Has returns true if the given element is in the set.

func (Set[T]) Intersection

func (s Set[T]) Intersection(o Set[T]) Set[T]

Intersection (s∩o) returns elements that are in both sets.

func (Set[T]) Remove

func (s Set[T]) Remove(element T)

Remove removes an element to the set.

func (Set[T]) Size

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

Size returns the number of elements in the set.

func (Set[T]) SymmetricDifference

func (s Set[T]) SymmetricDifference(o Set[T]) Set[T]

SymmetricDifference (s-o)∪(o-s) returns elements that are in the receiver set, but not the given set 'o', along with those that are in 'o', but not the receiver set.

func (Set[T]) ToSlice

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

ToSlice returns a slice of all the elements in the set.

func (Set[T]) ToSortedSlice

func (s Set[T]) ToSortedSlice(cmp func(a T, b T) int) []T

ToSortedSlice returns a sorted slice of all the elements in the set.

func (Set[T]) Union

func (s Set[T]) Union(o Set[T]) Set[T]

Union (s∪o) returns all elements from both sets.

Jump to

Keyboard shortcuts

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