AlgoPlus v0.1.0
Loading...
Searching...
No Matches
dsu Class Reference

disjoint set class More...

#include <disjoint_set.h>

Public Member Functions

 dsu (int64_t n)
 Construct a new dsu object.
 
int64_t find (int64_t i)
 find function
 
void join (int64_t i, int64_t j)
 join function
 
bool same (int64_t i, int64_t j)
 same function
 
std::vector< int64_t > get (int64_t i)
 
int64_t size (int64_t i)
 size function
 
int64_t get_max (int64_t i)
 get the maximum element of the set that i exists in
 
int64_t get_min (int64_t i)
 get the minimum element of the set that i exists in
 

Detailed Description

disjoint set class

Constructor & Destructor Documentation

◆ dsu()

dsu::dsu ( int64_t n)
inlineexplicit

Construct a new dsu object.

Parameters
nnumber of elements

Member Function Documentation

◆ find()

int64_t dsu::find ( int64_t i)
inline

find function

Parameters
ithe element we want to search
Returns
int64_t the set it exists in

◆ get_max()

int64_t dsu::get_max ( int64_t i)
inline

get the maximum element of the set that i exists in

Parameters
ithe object that we want to search for
Returns
int64_t the maximum element

◆ get_min()

int64_t dsu::get_min ( int64_t i)
inline

get the minimum element of the set that i exists in

Parameters
ithe object that we want to search for
Returns
int64_t the minimum element

◆ join()

void dsu::join ( int64_t i,
int64_t j )
inline

join function

Parameters
ifirst element
jsecond element union of i and j

◆ same()

bool dsu::same ( int64_t i,
int64_t j )
inline

same function

Parameters
ifirst element
jsecond element
Returns
true if i and j exists in the same set
false if i and j does not exist in the same set

◆ size()

int64_t dsu::size ( int64_t i)
inline

size function

Parameters
ielement we are looking for
Returns
int64_t the size of the set that i exists in

The documentation for this class was generated from the following file: