Commit 65f245e7 authored by Kevin Coulomb's avatar Kevin Coulomb

Correction d'erreurs

parent e60d1865
......@@ -124,7 +124,7 @@ public :
*
*/
std::string get_name(){
return _caracteristic_of_event.getName();
return (_caracteristic_of_event->get_name());
}
/*
......@@ -134,7 +134,7 @@ public :
*
*/
void set_name(std::string s){
_caracteristic_of_event.set_name(s);
_caracteristic_of_event->set_name(s);
}
......@@ -146,7 +146,7 @@ public :
*
*/
std::string getDescription(){
return _caracteristic_of_event.getDescription();
return _caracteristic_of_event->getDescription();
}
/*
......
......@@ -65,6 +65,17 @@ private :
void set_status(int status){
this->_status = status;
}
/*
*
*\fn get_tree()
*\brief Return the binary tree
*
*
*/
BinaryTree<E> * get_tree(){
return this->_tree;
}
/*
*
......@@ -83,7 +94,7 @@ private :
*
*/
bool is_free(){
return _status == free;
return _status == FREE;
}
/*
......@@ -143,7 +154,7 @@ private :
*
*/
void set_node(Node<E> * node){
this->_tree->current = node;
this->_tree->set_current_node(node);
}
/*
......@@ -161,7 +172,7 @@ private :
private :
std::list <E> _list;
std::list <E> *_list;
BinaryTree <E> *_tree;
/*
......@@ -203,7 +214,7 @@ private :
_temporary = new TableNode[_size];
}
TreeBuilder(std::list<E> l, BinaryTree<E> * t){
TreeBuilder(std::list<E>* l, BinaryTree<E> * t){
_size = 1;
_list = l;
_tree = t;
......@@ -317,7 +328,7 @@ private :
/*
*
*\fn build_tree()
*\brief Function that uses the list to build the tree
*\brief Function that uses the list to build the tree. At the end the list is removed from the memory
*
*/
void build_tree(){
......@@ -325,13 +336,17 @@ private :
int pos = 0;
int cpt;
int cptlimit=0;
// std::list<int>::iterator iter;
// std::list<E>::const_iterator iter;
BinaryTree <E> * father;
BinaryTree <E> * leftChild;
BinaryTree <E> * rightChild;
E item;
// Attention a la methode
if(_list.current() != NULL){
if(!_list->empty()){
int size_list = _size;
this->_beginning = 0;
......@@ -342,21 +357,21 @@ private :
this->_temporary = new TableNode[n];
// voir si go beginning est correct
this->_list = go_beginning();
item = _list->front();
// iter = _list.begin();
while (this->_list->has_next() ){
while (!_list->empty()){
// create a node with the current element of the list
create_binary_tree(_list->get_current(),tmp);
create_binary_tree(item,tmp);
// delete _list->front();
// Getting the first position free where we can insert the node in the table
pos = get_first_freebox();
// Set the node in the table
set_node(tmp.get_current_node(),pos);
set_node(tmp->get_current(),pos);
// To look if there is links that can already be put
tmp = _temporary[pos];
tmp = _temporary[pos].get_tree();
// If it is a leaf
if(pos == _beginning){
......@@ -364,10 +379,10 @@ private :
}
else{
// Previous node = left child
leftChild = _temporary[pos-1];
leftChild = _temporary[pos-1].get_tree();
leftChild->set_father(tmp.get_current_node());
tmp->set_left_child(leftChild->get_current_node());
leftChild->set_father(tmp);
tmp->set_left_child(leftChild);
// Removing the previous nodes in the table
for(cpt=_beginning;cpt<pos;cpt++){
......@@ -376,12 +391,12 @@ private :
}
}//end else
if(_temporary[pos+1].is_busy()){
if(_temporary[pos+1].is_occuped()){
rightChild = tmp;
tmp = _temporary[pos+1];
tmp = _temporary[pos+1].get_tree();
rightChild->set_father(tmp.get_current_node());
tmp->set_right_child(rightChild.get_current_node());
rightChild->set_father(tmp);
tmp->set_right_child(rightChild);
}
if ( cptlimit == limit ){
......@@ -389,26 +404,28 @@ private :
}
cptlimit ++;
// Attention a la methode get_next
this->_list = this->_list->get_next();
_list->pop_front();
item = _list->front();
// this->_list = this->_list->get_next();
}//endwhile
// Treating the last Node and filling the tree
create_binary_tree(_list->get_current(),tmp);
create_binary_tree(item,tmp);
pos = get_first_freebox();
set_node(tmp.get_current_node(),pos);
tmp = _temporary[pos];
set_node(tmp->get_current(),pos);
tmp = _temporary[pos].get_tree();
// If it is a leaf
if(pos == _beginning){
tmp->set_children(NULL,NULL);
}
else{
// Previous node = left child
leftChild = _temporary[pos-1];
leftChild = _temporary[pos-1].get_tree();
leftChild->set_father(tmp.get_current_node());
tmp->set_left_child(leftChild.get_current_node());
leftChild->set_father(tmp);
tmp->set_left_child(leftChild);
// Removing the previous nodes in the table
for(cpt=_beginning;cpt<pos;cpt++){
......@@ -417,9 +434,9 @@ private :
}
}//end else
if(_temporary[pos+1].is_busy()){
if(_temporary[pos+1].is_occuped()){
rightChild = tmp;
tmp = _temporary[pos+1].get_node();
tmp = _temporary[pos+1].get_tree();
rightChild->set_father(tmp);
tmp->set_right_child(rightChild);
......@@ -447,12 +464,16 @@ private :
*\param BinaryTree : A binary tree with the node field filled with the list parameter. Others remain NULL.
*
*/
void create_binary_tree(std::list<E> list, BinaryTree<E> * tree){
void create_binary_tree(E list, BinaryTree<E> * tree){
Node<E> * node = new Node<E>();
node->set_name((string)list.pop());
set_father(NULL);
set_children(NULL,NULL);
set_current(node);
Data<E> data;
//////////////////////////////////////////////////
// Data non rempli
///////////////////////////////////////////////
node->set_name((std::string)data.get_name());
tree->set_father(NULL);
tree->set_children(NULL,NULL);
tree->set_current_node(node);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment