-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisjointSetElement.hpp
More file actions
63 lines (48 loc) · 1.61 KB
/
DisjointSetElement.hpp
File metadata and controls
63 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#if !defined DISJOINT_SET_ELEMENT_HPP
#define DISJOINT_SET_ELEMENT_HPP
template <class T> class DisjointSetElement
{
public:
// Initializes data members, nothing more.
DisjointSetElement(T* element = 0,
DisjointSetElement<T>* parent = 0);
// Copy constructor
DisjointSetElement(const DisjointSetElement& dj_element);
// Does nothing.
~DisjointSetElement();
// For getting and setting the represented element.
T* getElement() const;
void setElement(T* element);
// For getting and setting parents
DisjointSetElement<T>* getParent() const;
void setParent(DisjointSetElement<T>* parent);
DisjointSetElement& operator=(const DisjointSetElement&);
private:
// The thing we're actually tracking
T* element;
// Follow this to get to the representative
DisjointSetElement<T>* parent;
};
//==============================================================================
template <class T> T* DisjointSetElement<T>::getElement() const
{
return element;
}
//==============================================================================
template <class T> void DisjointSetElement<T>::setElement(T* element)
{
this->element = element;
}
//==============================================================================
template <class T>
DisjointSetElement<T>* DisjointSetElement<T>::getParent() const
{
return parent;
}
//==============================================================================
template <class T>
void DisjointSetElement<T>::setParent(DisjointSetElement<T>* parent)
{
this->parent = parent;
}
#endif