Repository navigation
Expand file tree
/
Copy pathnode.cpp
More file actions
67 lines (54 loc) · 1.54 KB
/
Copy pathnode.cpp
File metadata and controls
67 lines (54 loc) · 1.54 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
64
65
66
67
/**
* @file node.cpp
* @author Henry Kaus (https://github.com/henrykaus)
* @brief Holds method definitions for the node class as apart of a bracket
* complete, balanced BST.
*
* @copyright Copyright (c) 2022
*/
#include "node.h"
using namespace std;
// Default constructor
node::node() : left(nullptr), right(nullptr)
{
spot.first.set_team("NONE", 0, 0, 0, 0);
spot.second.set_team("NONE", 0, 0, 0, 0);
}
// Copy constructor
node::node(const node & _source) : left(nullptr), right(nullptr)
{
copy_node(_source);
}
// Private copy helper
void node::copy_node(const node & _source)
{
spot.first = _source.spot.first;
spot.second = _source.spot.second;
}
// Parameterized constructor
node::node(const pair<team, team> & _spot) : left(nullptr), right(nullptr)
{
spot.first = _spot.first;
spot.second = _spot.second;
}
// Copy assignment operator
node & node::operator = (const node & _source)
{
if (this != &_source)
copy_node(_source);
return *this;
}
// Setters
void node::set_pair(const team & _first, const team & _second)
{
spot.first = _first;
spot.second = _second;
}
void node::set_pair_first(const team & _first) { spot.first = _first; }
void node::set_pair_second(const team & _second) { spot.second = _second; }
void node::set_left(node * _left) { left = _left; }
void node::set_right(node * _right) { right = _right; }
// Getters
const pair<team, team> & node::get_pair() const { return spot; }
node *& node::get_left() { return left; }
node *& node::get_right() { return right; }