Table of Contents

Mojo struct

UnionFind

@memory_only
struct UnionFind

Fields

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

Implemented traits

AnyType, Deinitable, Movable

Methods

__init__

fn def __init__(out self, size: Int)

Args:

  • size (Int)
  • self (Self)

Returns:

Self

Raises:

find

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

Args:

  • self (Self)
  • x (Int)

Returns:

Int

unite

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

Args:

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