unionfind

package
v1.3.60 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UnionFind

type UnionFind[T comparable] struct {
	// contains filtered or unexported fields
}

UnionFind is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets.

func New

func New[T comparable]() *UnionFind[T]

NewUnionFind creates and returns a new UnionFind instance.

func (*UnionFind[T]) Find

func (uf *UnionFind[T]) Find(x T) T

Find returns the representative (root) of the set that x belongs to.

func (*UnionFind[T]) Groups

func (uf *UnionFind[T]) Groups() [][]T

func (*UnionFind[T]) Groups2

func (uf *UnionFind[T]) Groups2() iter.Seq2[int, []T]

func (*UnionFind[T]) Union

func (uf *UnionFind[T]) Union(x, y T) bool

Union merges the sets containing x and y.

Jump to

Keyboard shortcuts

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