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 ¶
- type FormatFunc
- type Set
- func New[T any](equal generic.EqualFunc[T], vals ...T) Set[T]
- func NewSorted[T any](compare generic.CompareFunc[T], vals ...T) Set[T]
- func NewSortedWithFormat[T any](compare generic.CompareFunc[T], format FormatFunc[T], vals ...T) Set[T]
- func NewStable[T any](equal generic.EqualFunc[T], vals ...T) Set[T]
- func NewStableWithFormat[T any](equal generic.EqualFunc[T], format FormatFunc[T], vals ...T) Set[T]
- func NewWithFormat[T any](equal generic.EqualFunc[T], format FormatFunc[T], vals ...T) Set[T]
- func Partitions[T any](s Set[T]) Set[Set[Set[T]]]
- func Powerset[T any](s Set[T]) Set[Set[T]]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormatFunc ¶ added in v0.12.0
FormatFunc is a function type for formatting a set into a single string representation.
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 NewSorted ¶ added in v0.11.0
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 ¶ added in v0.11.0
func NewSortedWithFormat[T any](compare generic.CompareFunc[T], format FormatFunc[T], vals ...T) Set[T]
NewSortedWithFormat creates a new sorted set with a custom format for String method.
func NewStable ¶ added in v0.11.0
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 ¶ added in v0.11.0
func NewStableWithFormat[T any](equal generic.EqualFunc[T], format FormatFunc[T], vals ...T) Set[T]
NewStableWithFormat creates a new stable set with a custom format for String method.
func NewWithFormat ¶ added in v0.10.3
func NewWithFormat[T any](equal generic.EqualFunc[T], format FormatFunc[T], vals ...T) Set[T]
NewWithFormat creates a new set with a custom format for String method.
func Partitions ¶ added in v0.4.2
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