Table of Contents

Mojo struct

UnionFind

@memory_only
struct UnionFind

Fields

  • parent (List[Int])
  • rank (List[Int])

Implemented traits

AnyType, ImplicitlyDestructible

Methods

__init__

fn __init__(out self, size: Int)

Args:

  • size (Int)
  • self (Self)

Returns:

Self

Raises:

find

fn find(mut self, x: Int) -> Int

Args:

  • self (Self)
  • x (Int)

Returns:

Int

unite

fn unite(mut self, x: Int, y: Int)

Args:

  • self (Self)
  • x (Int)
  • y (Int)