Table of Contents

Mojo struct

UnionFind

@memory_only
struct UnionFind

Fields

  • parent (List[Scalar[DType.int]])
  • rank (List[Scalar[DType.int]])

Implemented traits

AnyType, ImplicitlyDestructible

Methods

__init__

def __init__(out self, size: Int)

Args:

  • size (Int)
  • self (Self)

Returns:

Self

Raises:

find

def find(mut self, x: Scalar[DType.int]) -> Scalar[DType.int]

Args:

  • self (Self)
  • x (Scalar)

Returns:

Scalar

unite

def unite(mut self, x: Scalar[DType.int], y: Scalar[DType.int])

Args:

  • self (Self)
  • x (Scalar)
  • y (Scalar)