source: tags/ms_r16q3/PRIMER_DESIGN/PRD_Node.cxx

Last change on this file was 8902, checked in by westram, 12 years ago
  • fixed cppcheck warnings
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1#include "PRD_Node.hxx"
2
3using namespace std;
4
5//
6// Constructors
7//
8void 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
21Node::Node (Node* parent_, char base_, PRD_Sequence_Pos last_index_, PRD_Sequence_Pos offset_)
22{
23  init (parent_, base_, last_index_, offset_);
24}
25
26Node::Node (Node* parent_, char base_, PRD_Sequence_Pos last_index_)
27{
28  init (parent_, base_, last_index_, 0);
29}
30
31Node::Node (Node* parent_, char base_)
32{
33  init (parent_, base_, 0, 0);
34}
35
36Node::Node ()
37{
38  init (NULL, ' ', 0, 0);
39}
40
41
42//
43// Destructor
44//
45Node::~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//
59void 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}
Note: See TracBrowser for help on using the repository browser.