GlobeEngine
Bintree.h
Go to the documentation of this file.
1 //
2 // Created by Matthias Thöny on 1/11/12.
3 // Copyright (c) 2012 University of Zuerich. All rights reserved.
4 //
5 #ifndef VMML_Bintree_h
6 #define VMML_Bintree_h
7 
8 #include "BintreeNode.h"
9 
10 namespace geData {
11  template <class T>
12  class Bintree
13  {
14  protected:
16 
17  public:
18  //constructors and destructor
19  Bintree() {}
20  Bintree(T _data): root(new BintreeNode<T>(_data)){}
21  virtual ~Bintree() {
22  if(this->root != NULL)
23  {
24  delete this->root;
25  }
26  }
27 
28  //insert in a heap structure
29  bool insert(T data)
30  {
31  if(this->root == 0L)
32  {
33  this->root = new BintreeNode<T>(data);
34  this->root->setData(data);
35  return true;
36 
37  }else{
38  return this->root->insert(data);
39  }
40  }
41 
42  bool remove(T _data){
43  std::cout << "TODO" << std::endl;
44  return false;
45  }
46 
47  void printInorder() {
48  if(this->root != 0L)
49  {
50  this->root->printInorder();
51  }
52  std::cout << std::endl;
53  }
54 
55  void printPostorder() {
56  if(root != 0L)
57  {
58  root->printPostorder();
59  }
60  }
61 
62  void printEuler() {
63  if(root != 0L)
64  {
65  root->Euler();
66  }
67  }
68  };
69 }
70 #endif
71 
virtual void printInorder()
Definition: BintreeNode.h:120
Definition: Bintree.h:12
Bintree()
Definition: Bintree.h:19
Definition: AvalancheTrainingSimulationEngine.h:39
Definition: BintreeNode.h:12
void setData(T data)
Definition: BintreeNode.h:36
virtual bool insert(T data)
Definition: BintreeNode.h:152
BintreeNode< T > * root
Definition: Bintree.h:15
void printEuler()
Definition: Bintree.h:62
void printInorder()
Definition: Bintree.h:47
Bintree(T _data)
Definition: Bintree.h:20
bool insert(T data)
Definition: Bintree.h:29
void printPostorder()
Definition: Bintree.h:55
virtual void printPostorder()
Definition: BintreeNode.h:130
virtual ~Bintree()
Definition: Bintree.h:21