Mantid
|
DisjointElement : Cluster item used in a disjoint-set data structure. More...
#include <DisjointElement.h>
Public Member Functions | |
DisjointElement () | |
Default constructor. More... | |
DisjointElement (const DisjointElement &other) | |
Copy constructor. More... | |
DisjointElement (const int id) | |
Constructor. More... | |
int | getId () const |
Get Id. More... | |
DisjointElement * | getParent () const |
Get parent element. More... | |
int | getRank () const |
Get the current rank. More... | |
int | getRoot () const |
Get root id. More... | |
int | incrementRank () |
Increment the rank. More... | |
bool | isEmpty () const |
Is empty. More... | |
bool | operator< (const DisjointElement &other) const |
Less than. More... | |
DisjointElement & | operator= (const DisjointElement &other) |
Assignment operator. More... | |
bool | operator> (const DisjointElement &other) const |
Greater than. More... | |
void | setId (int id) |
Set the id. More... | |
void | unionWith (DisjointElement *other) |
Union with other. More... | |
virtual | ~DisjointElement ()=default |
Destructor. More... | |
Private Member Functions | |
int | compress () |
Compress the tree such that element's parent becomes it's root parent. More... | |
bool | hasParent () const |
Determine if this instance really has a parent or whether it is a singleton. More... | |
void | setParent (DisjointElement *other) |
Setter for the parent element. More... | |
Private Attributes | |
int | m_id |
Identifier. More... | |
DisjointElement * | m_parent |
Parent element. More... | |
int | m_rank |
Current rank. More... | |
DisjointElement : Cluster item used in a disjoint-set data structure.
Definition at line 16 of file DisjointElement.h.
Mantid::Crystal::DisjointElement::DisjointElement | ( | ) |
Default constructor.
Creates an 'empty' disjoint element.
Definition at line 14 of file DisjointElement.cpp.
Mantid::Crystal::DisjointElement::DisjointElement | ( | const int | id | ) |
|
virtualdefault |
Destructor.
Mantid::Crystal::DisjointElement::DisjointElement | ( | const DisjointElement & | other | ) |
Copy constructor.
other | : Other disjoint element to copy. |
Definition at line 26 of file DisjointElement.cpp.
References m_parent.
|
private |
Compress the tree such that element's parent becomes it's root parent.
Note that compression does NOT alter ranks.
Definition at line 67 of file DisjointElement.cpp.
References getParent(), getRoot(), hasParent(), and m_parent.
Referenced by unionWith().
int Mantid::Crystal::DisjointElement::getId | ( | ) | const |
Get Id.
Getter for the id.
Definition at line 53 of file DisjointElement.cpp.
References m_id.
Referenced by Mantid::Crystal::ClusterRegister::merge().
DisjointElement * Mantid::Crystal::DisjointElement::getParent | ( | ) | const |
Get parent element.
Getter for the parent element.
Definition at line 59 of file DisjointElement.cpp.
References m_parent.
Referenced by compress(), and unionWith().
int Mantid::Crystal::DisjointElement::getRank | ( | ) | const |
Get the current rank.
Getter for the rank.
Definition at line 110 of file DisjointElement.cpp.
References m_rank.
int Mantid::Crystal::DisjointElement::getRoot | ( | ) | const |
Get root id.
Getter for the root id.
Definition at line 86 of file DisjointElement.cpp.
References getRoot(), m_id, and m_parent.
Referenced by compress(), getRoot(), and Mantid::Crystal::ImplClusterRegister::insert().
|
private |
Determine if this instance really has a parent or whether it is a singleton.
Definition at line 80 of file DisjointElement.cpp.
References m_parent.
Referenced by compress().
int Mantid::Crystal::DisjointElement::incrementRank | ( | ) |
Increment the rank.
Definition at line 104 of file DisjointElement.cpp.
References m_rank.
bool Mantid::Crystal::DisjointElement::isEmpty | ( | ) | const |
Is empty.
Determine if the disjoint element is empty.
Empty corresponds to an unassigned element.
Definition at line 117 of file DisjointElement.cpp.
References m_id.
Referenced by Mantid::Crystal::ClusterRegister::merge().
|
inline |
Less than.
Definition at line 45 of file DisjointElement.h.
DisjointElement & Mantid::Crystal::DisjointElement::operator= | ( | const DisjointElement & | other | ) |
Assignment operator.
other | Element to assign from |
Definition at line 40 of file DisjointElement.cpp.
|
inline |
Greater than.
Definition at line 47 of file DisjointElement.h.
void Mantid::Crystal::DisjointElement::setId | ( | int | id | ) |
Set the id.
Set the id for the element.
id | Id to use |
Definition at line 160 of file DisjointElement.cpp.
References m_id.
|
private |
Setter for the parent element.
other | : New parent |
Definition at line 98 of file DisjointElement.cpp.
References m_parent.
void Mantid::Crystal::DisjointElement::unionWith | ( | DisjointElement * | other | ) |
Union with other.
Union disjoint sets.
Union happens w.r.t the parent of on or the other sets. Early exit if both have the same root node already. Generally, the set with the highest rank becomes the parent. If ranks are equal, then one is chosen to be the parent, and that's sets rank is incremented.
other |
Definition at line 127 of file DisjointElement.cpp.
References compress(), getParent(), Mantid::Geometry::x, and Mantid::Geometry::y.
Referenced by Mantid::Crystal::unionElements().
|
private |
Identifier.
Definition at line 60 of file DisjointElement.h.
Referenced by getId(), getRoot(), isEmpty(), operator=(), and setId().
|
private |
Parent element.
Definition at line 56 of file DisjointElement.h.
Referenced by compress(), DisjointElement(), getParent(), getRoot(), hasParent(), operator=(), and setParent().
|
private |
Current rank.
Definition at line 58 of file DisjointElement.h.
Referenced by getRank(), incrementRank(), and operator=().