27 : m_parent(other.m_parent), m_rank(other.m_rank), m_id(other.m_id) {
30 if (other.m_parent == &other) {
129 if (other->getRoot() != this->getRoot())
138 if (
x->getRank() >
y->getRank()) {
142 if (
x->getRank() ==
y->getRank()) {
DisjointElement : Cluster item used in a disjoint-set data structure.
bool isEmpty() const
Is empty.
void unionWith(DisjointElement *other)
Union with other.
DisjointElement * getParent() const
Get parent element.
int getRank() const
Get the current rank.
int getRoot() const
Get root id.
void setId(int id)
Set the id.
int incrementRank()
Increment the rank.
DisjointElement()
Default constructor.
int compress()
Compress the tree such that element's parent becomes it's root parent.
bool hasParent() const
Determine if this instance really has a parent or whether it is a singleton.
DisjointElement * m_parent
Parent element.
void setParent(DisjointElement *other)
Setter for the parent element.
DisjointElement & operator=(const DisjointElement &other)
Assignment operator.
void unionElements(DisjointElement *a, DisjointElement *b)
Convenience non-member function.