1 | #include "PRD_Node.hxx" |
---|
2 | |
---|
3 | using namespace std; |
---|
4 | |
---|
5 | // |
---|
6 | // Constructors |
---|
7 | // |
---|
8 | void Node::init (Node* parent_, char base_, PRD_Sequence_Pos last_index_, PRD_Sequence_Pos offset_) |
---|
9 | { |
---|
10 | parent = parent_; |
---|
11 | child[0] = NULL; |
---|
12 | child[1] = NULL; |
---|
13 | child[2] = NULL; |
---|
14 | child[3] = NULL; |
---|
15 | base = base_; |
---|
16 | last_base_index = last_index_; |
---|
17 | child_bits = 0; |
---|
18 | offset = offset_; |
---|
19 | } |
---|
20 | |
---|
21 | Node::Node (Node* parent_, char base_, PRD_Sequence_Pos last_index_, PRD_Sequence_Pos offset_) |
---|
22 | { |
---|
23 | init (parent_, base_, last_index_, offset_); |
---|
24 | } |
---|
25 | |
---|
26 | Node::Node (Node* parent_, char base_, PRD_Sequence_Pos last_index_) |
---|
27 | { |
---|
28 | init (parent_, base_, last_index_, 0); |
---|
29 | } |
---|
30 | |
---|
31 | Node::Node (Node* parent_, char base_) |
---|
32 | { |
---|
33 | init (parent_, base_, 0, 0); |
---|
34 | } |
---|
35 | |
---|
36 | Node::Node () |
---|
37 | { |
---|
38 | init (NULL, ' ', 0, 0); |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | // |
---|
43 | // Destructor |
---|
44 | // |
---|
45 | Node::~Node () |
---|
46 | { |
---|
47 | if (child[0]) delete child[0]; |
---|
48 | if (child[1]) delete child[1]; |
---|
49 | if (child[2]) delete child[2]; |
---|
50 | if (child[3]) delete child[3]; |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | // |
---|
55 | // print |
---|
56 | // |
---|
57 | // recursively print Node and its children |
---|
58 | // |
---|
59 | void Node::print () { |
---|
60 | printf ("[%c,%li,%li,%u (", base, last_base_index, offset, child_bits); |
---|
61 | if (child[0]) { child[0]->print(); printf(","); } |
---|
62 | if (child[1]) { child[1]->print(); printf(","); } |
---|
63 | if (child[2]) { child[2]->print(); printf(","); } |
---|
64 | if (child[3]) { child[3]->print(); } |
---|
65 | printf(")]"); |
---|
66 | } |
---|