[Avl-cvs] avl/src avl.cpp,1.21,1.22 bst.cpp,1.19,1.20 bst.h,1.7,1.8
Brought to you by:
hetfield666,
jah2003
From: Gianlorenzo D\\'A. <ja...@us...> - 2004-09-17 14:12:23
|
Update of /cvsroot/avl/avl/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3720 Modified Files: avl.cpp bst.cpp bst.h Log Message: Index: bst.h =================================================================== RCS file: /cvsroot/avl/avl/src/bst.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** bst.h 8 Sep 2004 10:14:46 -0000 1.7 --- bst.h 17 Sep 2004 14:12:14 -0000 1.8 *************** *** 36,40 **** Bst *parent; ! void erase(); void print_ric( int, int ); #ifdef GUI --- 36,40 ---- Bst *parent; ! Bst *erase(); void print_ric( int, int ); #ifdef GUI *************** *** 71,75 **** Bst *search(int); void insert(int); ! void erase(int); Bst *max(); Bst *min(); --- 71,75 ---- Bst *search(int); void insert(int); ! Bst *erase(int); Bst *max(); Bst *min(); Index: bst.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/bst.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** bst.cpp 17 Sep 2004 10:41:17 -0000 1.19 --- bst.cpp 17 Sep 2004 14:12:14 -0000 1.20 *************** *** 201,205 **** /*Elimina il nodo corrente dall'albero ( viene richiamato da erase(int) ) */ ! void Bst::erase() { Bst *aux1, *aux2; --- 201,205 ---- /*Elimina il nodo corrente dall'albero ( viene richiamato da erase(int) ) */ ! Bst *Bst::erase() { Bst *aux1, *aux2; *************** *** 234,249 **** delete aux1; //ATT!!!!!!! } /* Elimina il nodo di valore key dall'albero*/ ! void Bst::erase(int key) { ! Bst *aux; aux = search( key ); //si cerca il nodo da eliminare if( aux ) //Se la ricerca ha avuto esito positivo si elimina il nodo { ! aux->erase(); //delete aux; } } --- 234,258 ---- delete aux1; //ATT!!!!!!! + if( aux2 ) + return aux2; + else + return this; } /* Elimina il nodo di valore key dall'albero*/ ! Bst *Bst::erase(int key) { ! Bst *aux, *aux1; aux = search( key ); //si cerca il nodo da eliminare if( aux ) //Se la ricerca ha avuto esito positivo si elimina il nodo { ! aux1 = aux->erase(); ! fprintf(stderr,"1"); ! if( aux == this ) ! return aux1; //delete aux; } + return this; + } Index: avl.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/avl.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** avl.cpp 17 Sep 2004 12:46:43 -0000 1.21 --- avl.cpp 17 Sep 2004 14:12:14 -0000 1.22 *************** *** 137,141 **** gtk_widget_destroy (dialog);} else { ! aux_bst->erase(value); popup_window(1,"deletion", value); } --- 137,141 ---- gtk_widget_destroy (dialog);} else { ! aux_bst = aux_bst->erase(value); popup_window(1,"deletion", value); } |