Commit a7fa2380 authored by Kevin Coulomb's avatar Kevin Coulomb

Correction de fautes dans le manuel technique

parent 4b021d87
...@@ -107,7 +107,7 @@ public : ...@@ -107,7 +107,7 @@ public :
* *
*/ */
bool has_children(){ bool has_children(){
return ((_left_child == NULL)&&(_right_child==NULL)); return !((_left_child == NULL)&&(_right_child==NULL));
} }
......
/*
J'ai besoin d'ajouter a la structure node :
1 intervalle pour dire la taille de l'intervalle ou je suis
1 tableau de 4 intervalles donnant les intervalles a conflit
Un tableau de 2 entiers donnant si les fils sont pas encore parcours ( 0 ), affichable ( 1 ), non affichable ( 2 ), ...
Peut etre un booleen donnant le fait que l'on soit affiche ou pas
*/
/* /*
* *
*\file tree/Node.hpp *\file tree/Node.hpp
......
...@@ -84,7 +84,7 @@ private : ...@@ -84,7 +84,7 @@ private :
* *
*/ */
bool is_occuped(){ bool is_occuped(){
return _status == OCCUPED; return (_status == OCCUPED);
} }
/* /*
...@@ -94,7 +94,7 @@ private : ...@@ -94,7 +94,7 @@ private :
* *
*/ */
bool is_free(){ bool is_free(){
return _status == FREE; return (_status == FREE);
} }
/* /*
...@@ -104,7 +104,7 @@ private : ...@@ -104,7 +104,7 @@ private :
* *
*/ */
bool is_locked(){ bool is_locked(){
return _status == LOCKED; return (_status == LOCKED);
} }
/* /*
...@@ -114,7 +114,7 @@ private : ...@@ -114,7 +114,7 @@ private :
* *
*/ */
void set_busy(){ void set_busy(){
_status = OCCUPED; this->_status = OCCUPED;
} }
/* /*
...@@ -124,7 +124,7 @@ private : ...@@ -124,7 +124,7 @@ private :
* *
*/ */
void set_free(){ void set_free(){
_status = FREE; this->_status = FREE;
} }
/* /*
...@@ -134,7 +134,7 @@ private : ...@@ -134,7 +134,7 @@ private :
* *
*/ */
void set_locked(){ void set_locked(){
_status = LOCKED; this->_status = LOCKED;
} }
/* /*
...@@ -154,7 +154,7 @@ private : ...@@ -154,7 +154,7 @@ private :
* *
*/ */
void set_node(Node<E> * node){ void set_node(Node<E> * node){
this->_tree->set_current_node(node); (this->_tree)->set_current_node(node);
} }
/* /*
...@@ -189,7 +189,7 @@ private : ...@@ -189,7 +189,7 @@ private :
* *
* *
*/ */
TableNode *_temporary;// = new TableNode[size]; TableNode *_temporary;
/* /*
* *
...@@ -214,12 +214,12 @@ private : ...@@ -214,12 +214,12 @@ private :
_temporary = new TableNode[_size]; _temporary = new TableNode[_size];
} }
TreeBuilder(std::list<E>* l, BinaryTree<E> * t){ TreeBuilder(std::list<E>* list, BinaryTree<E> * tree){
_size = 1; this->_size = 1;
_list = l; this->_list = list;
_tree = t; this->_tree = tree;
_beginning = 0; this->_beginning = 0;
_temporary = new TableNode[_size]; this->_temporary = new TableNode[_size];
} }
/* /*
...@@ -240,7 +240,7 @@ private : ...@@ -240,7 +240,7 @@ private :
* *
*/ */
void inc_beginning(){ void inc_beginning(){
this->_beginning ++; (this->_beginning) ++;
} }
/* /*
...@@ -290,6 +290,7 @@ private : ...@@ -290,6 +290,7 @@ private :
*\brief Clear the memory linked to the binary tree *\brief Clear the memory linked to the binary tree
* *
*/ */
///////////////////////////////ATTENTION A FAIRE LE CLEAR DANS LE BINARY_TREE
void clear_tree(){ void clear_tree(){
BinaryTree<E> * copy = _tree->getRoot(); BinaryTree<E> * copy = _tree->getRoot();
copy->clear_tree(); copy->clear_tree();
...@@ -332,20 +333,18 @@ private : ...@@ -332,20 +333,18 @@ private :
* *
*/ */
void build_tree(){ void build_tree(){
BinaryTree <E> * tmp; BinaryTree <E> * tmp;
int pos = 0; int pos = 0;
int cpt; int cpt;
int cptlimit=0; int cptlimit=0;
// std::list<int>::iterator iter;
// std::list<E>::const_iterator iter;
BinaryTree <E> * father; BinaryTree <E> * father;
BinaryTree <E> * leftChild; BinaryTree <E> * left_child;
BinaryTree <E> * rightChild; BinaryTree <E> * right_child;
E item; E item;
// If the list is not empty
if(!_list->empty()){ if(!_list->empty()){
int size_list = _size; int size_list = _size;
this->_beginning = 0; this->_beginning = 0;
...@@ -358,45 +357,46 @@ private : ...@@ -358,45 +357,46 @@ private :
this->_temporary = new TableNode[n]; this->_temporary = new TableNode[n];
item = _list->front(); item = _list->front();
// iter = _list.begin();
// While the whole tree has not been built
while (!_list->empty()){ while (!_list->empty()){
// create a node with the current element of the list // create a node with the current element of the list
create_binary_tree(item,tmp); create_binary_tree(item,tmp);
// delete _list->front();
// Getting the first position free where we can insert the node in the table // Getting the first position free where we can insert the node in the table
pos = get_first_freebox(); pos = get_first_freebox();
// Set the node in the table // Set the node in the table
set_node(tmp->get_current(),pos); set_node(tmp->get_current(),pos);
// To look if there is links that can already be put // To look if there are links that can already be put
tmp = _temporary[pos].get_tree(); tmp = _temporary[pos].get_tree();
// If it is a leaf // If it is a leaf
if(pos == _beginning){ if(pos == _beginning){
tmp->set_children(NULL,NULL); tmp->set_children(NULL,NULL);
} }
else{ else{ // Previous node = left child
// Previous node = left child left_child = _temporary[pos-1].get_tree();
leftChild = _temporary[pos-1].get_tree();
leftChild->set_father(tmp); left_child->set_father(tmp);
tmp->set_left_child(leftChild); tmp->set_left_child(left_child);
// Removing the previous nodes in the table // Removing all the previous nodes in the table
for(cpt=_beginning;cpt<pos;cpt++){ for(cpt=_beginning;cpt<pos;cpt++){
_temporary[cpt].set_free(); _temporary[cpt].set_free();
_temporary[cpt].set_node(NULL); _temporary[cpt].set_node(NULL);
} }
}//end else }//end else
// If there is its father (--> i am its right child)
if(_temporary[pos+1].is_occuped()){ if(_temporary[pos+1].is_occuped()){
rightChild = tmp; right_child = tmp;
tmp = _temporary[pos+1].get_tree(); tmp = _temporary[pos+1].get_tree();
rightChild->set_father(tmp); right_child->set_father(tmp);
tmp->set_right_child(rightChild); tmp->set_right_child(right_child);
} }
if ( cptlimit == limit ){ if ( cptlimit == limit ){
...@@ -404,10 +404,10 @@ private : ...@@ -404,10 +404,10 @@ private :
} }
cptlimit ++; cptlimit ++;
// ATTENTION VOIR SI ON DETRUIT LE NOEUD DE LA LISTE ICI
_list->pop_front(); _list->pop_front();
item = _list->front(); item = _list->front();
// this->_list = this->_list->get_next(); tmp = NULL;
}//endwhile }//endwhile
...@@ -420,14 +420,12 @@ private : ...@@ -420,14 +420,12 @@ private :
if(pos == _beginning){ if(pos == _beginning){
tmp->set_children(NULL,NULL); tmp->set_children(NULL,NULL);
} }
else{ else{ // Previous node = left child
// Previous node = left child left_child = _temporary[pos-1].get_tree();
leftChild = _temporary[pos-1].get_tree(); left_child->set_father(tmp);
tmp->set_left_child(left_child);
leftChild->set_father(tmp);
tmp->set_left_child(leftChild);
// Removing the previous nodes in the table // Removing all the previous nodes in the table
for(cpt=_beginning;cpt<pos;cpt++){ for(cpt=_beginning;cpt<pos;cpt++){
_temporary[cpt].set_free(); _temporary[cpt].set_free();
_temporary[cpt].set_node(NULL); _temporary[cpt].set_node(NULL);
...@@ -435,18 +433,18 @@ private : ...@@ -435,18 +433,18 @@ private :
}//end else }//end else
if(_temporary[pos+1].is_occuped()){ if(_temporary[pos+1].is_occuped()){
rightChild = tmp; right_child = tmp;
tmp = _temporary[pos+1].get_tree(); tmp = _temporary[pos+1].get_tree();
rightChild->set_father(tmp); right_child->set_father(tmp);
tmp->set_right_child(rightChild); tmp->set_right_child(right_child);
} }
this->_tree = tmp; this->_tree = tmp;
} }
else{ else{
this->_beginning = -1; this->_beginning = 0;
this->_tree = new BinaryTree<E>(); this->_tree = new BinaryTree<E>();
} }
} }
...@@ -492,7 +490,7 @@ private : ...@@ -492,7 +490,7 @@ private :
/* /*
* *
*\fn get_power(int size) *\fn get_power(int size)
*\brief Calculate and return the number j to have 2^j<size<2^(j+1) *\brief Calculate and return the number j+1 to have 2^j<size<2^(j+1)
* *
*/ */
int get_power(int size){ int get_power(int size){
......
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