snippets 0.1.0
Loading...
Searching...
No Matches
hsc_snippets::DisjointSet Class Reference

#include <disjoint_set.hpp>

Public Member Functions

 DisjointSet (int size)
 Construct a new Disjoint Set object.
 
int find (int p)
 Find the set containing element 'p'.
 
void unionSets (int p, int q)
 Union the sets containing elements 'p' and 'q'.
 
int getCount () const
 Get the number of distinct sets.
 

Constructor & Destructor Documentation

◆ DisjointSet()

hsc_snippets::DisjointSet::DisjointSet ( int size)
inlineexplicit

Construct a new Disjoint Set object.

Parameters
sizeThe number of elements in the set.

Member Function Documentation

◆ find()

int hsc_snippets::DisjointSet::find ( int p)
inline

Find the set containing element 'p'.

Parameters
pThe element to find.
Returns
The set containing element 'p'.

◆ getCount()

int hsc_snippets::DisjointSet::getCount ( ) const
inline

Get the number of distinct sets.

Returns
The number of distinct sets.

◆ unionSets()

void hsc_snippets::DisjointSet::unionSets ( int p,
int q )
inline

Union the sets containing elements 'p' and 'q'.

Parameters
pThe first element.
qThe second element.

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