set

package
v0.0.0-...-db13919 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package set implements a set data structure. A set is a collection of objects without any particular order.

Package set implements a set data structure. A set is a collection of objects without any particular order.

Package set implements a set data structure. A set is a collection of objects without any particular order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T any] interface {
	fmt.Stringer
	generic.Equaler[Set[T]]
	generic.Cloner[Set[T]]
	generic.Collection1[T]

	CloneEmpty() Set[T]
	IsSubset(Set[T]) bool
	IsSuperset(Set[T]) bool
	Union(...Set[T]) Set[T]
	Intersection(...Set[T]) Set[T]
	Difference(...Set[T]) Set[T]
}

Set represents a set abstract data type.

func New

func New[T any](equal generic.EqualFunc[T], vals ...T) Set[T]

New creates a new set that does not maintain any specific order for its members.

func NewSorted

func NewSorted[T any](compare generic.CompareFunc[T], vals ...T) Set[T]

NewSorted creates a new set that maintains its members in sorted order. This is useful for cases where a sorted ordering of set members is required.

func NewSortedWithFormat

func NewSortedWithFormat[T any](compare generic.CompareFunc[T], format StringFormat[T], vals ...T) Set[T]

NewSortedWithFormat creates a new sorted set with a custom format for String method.

func NewStable

func NewStable[T any](equal generic.EqualFunc[T], vals ...T) Set[T]

NewStable creates a new set that preserves the order in which members are added. This is useful for cases where a deterministic ordering of set members is required.

func NewStableWithFormat

func NewStableWithFormat[T any](equal generic.EqualFunc[T], format StringFormat[T], vals ...T) Set[T]

NewStableWithFormat creates a new stable set with a custom format for String method.

func NewWithFormat

func NewWithFormat[T any](equal generic.EqualFunc[T], format StringFormat[T], vals ...T) Set[T]

NewWithFormat creates a new set with a custom format for String method.

func Partitions

func Partitions[T any](s Set[T]) Set[Set[Set[T]]]

Partitions creates and returns the set of all partitions for a given set. A partition of a set is a grouping of its elements into non-empty subsets, in such a way that every element is included in exactly one subset.

Set[T]            A set
Set[Set[T]        A partition (a set of non-empty disjoint subsets with every element included)
Set[Set[Set[T]]]  The set of all partitions

func Powerset

func Powerset[T any](s Set[T]) Set[Set[T]]

Powerset creates and returns the power set of a given set. The power set of a set is the set of all subsets, including the empty set and the set itself.

Set[T]      A set
Set[Set[T]  The power set (the set of all subsets)

type StringFormat

type StringFormat[T any] func([]T) string

StringFormat is a function type for formatting a set into a single string representation.

Jump to

Keyboard shortcuts

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