General union/find implementation. More...
#include <UnionFind.hpp>
Public Member Functions | |
UnionFind () | |
Constructor. | |
void | Clear () |
Sets all elements to be isolated. | |
bool | IsRoot (int x) const |
Returns true if x is the captain of a group. | |
int | GetRoot (int x) const |
Gets the captain of x's group. | |
int | UnionGroups (int x, int y) |
Unions two sets of elements. | |
Private Attributes | |
std::vector< int > | m_sets |
Static Private Attributes | |
static const int | ISOLATED = -1 |
Flag denoting that the element is its own group. |
General union/find implementation.
Definition at line 19 of file UnionFind.hpp.
Constructor.
All elements are initially isolated.
Definition at line 46 of file UnionFind.hpp.
References UnionFind< S >::Clear().
void UnionFind< S >::Clear | ( | ) | [inline] |
Sets all elements to be isolated.
Definition at line 53 of file UnionFind.hpp.
References UnionFind< S >::ISOLATED, and UnionFind< S >::m_sets.
Referenced by UnionFind< S >::UnionFind().
int UnionFind< S >::GetRoot | ( | int | x | ) | const [inline] |
Gets the captain of x's group.
Definition at line 66 of file UnionFind.hpp.
References UnionFind< S >::m_sets.
Referenced by UnionFind< S >::UnionGroups().
bool UnionFind< S >::IsRoot | ( | int | x | ) | const [inline] |
Returns true if x is the captain of a group.
Definition at line 60 of file UnionFind.hpp.
References UnionFind< S >::m_sets.
int UnionFind< S >::UnionGroups | ( | int | x, | |
int | y | |||
) | [inline] |
Unions two sets of elements.
Definition at line 75 of file UnionFind.hpp.
References UnionFind< S >::GetRoot(), and UnionFind< S >::m_sets.
Flag denoting that the element is its own group.
Definition at line 40 of file UnionFind.hpp.
Referenced by UnionFind< S >::Clear().
Definition at line 42 of file UnionFind.hpp.
Referenced by UnionFind< S >::Clear(), UnionFind< S >::GetRoot(), UnionFind< S >::IsRoot(), and UnionFind< S >::UnionGroups().