[Avl-cvs] avl/src avl.cpp,1.18,1.19 bst.cpp,1.18,1.19
Brought to you by:
hetfield666,
jah2003
From: Patrizio B. <het...@us...> - 2004-09-17 10:41:27
|
Update of /cvsroot/avl/avl/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25600 Modified Files: avl.cpp bst.cpp Log Message: some bug fixed, some corrections. bug # = 3 Index: bst.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/bst.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** bst.cpp 16 Sep 2004 17:51:16 -0000 1.18 --- bst.cpp 17 Sep 2004 10:41:17 -0000 1.19 *************** *** 20,32 **** #include "bst.h" - /*Bst::Bst() - { - //Bst(0); - setValue(0); - setLeft(NULL); - setRight(NULL); - setParent(NULL); - }*/ - Bst::Bst(int val ) { --- 20,23 ---- *************** *** 436,443 **** aux=iter2; //ricorda a che punto stiamo, appende tutti i rami destri e riprende ! if( getRight() ) { msg=NULL; ! msg = g_strdup_printf ("(son of: %d) Right Value: %d", getValue(),getRight()->getValue()); gtk_tree_store_append (GTK_TREE_STORE (store), &iter1,&iter2); gtk_tree_store_set (GTK_TREE_STORE (store), &iter1, 0, msg, -1); --- 427,434 ---- aux=iter2; //ricorda a che punto stiamo, appende tutti i rami destri e riprende ! if( this->getRight() ) { msg=NULL; ! msg = g_strdup_printf ("(son of: %d) Right Value: %d", (int)getValue(),(int)getRight()->getValue()); gtk_tree_store_append (GTK_TREE_STORE (store), &iter1,&iter2); gtk_tree_store_set (GTK_TREE_STORE (store), &iter1, 0, msg, -1); *************** *** 445,449 **** iter2=iter1; ! getRight()->print_gtk_ric(); } iter2=aux; //riprende dopo aver appeso i rami destri, e termina con i rami sinistri --- 436,440 ---- iter2=iter1; ! this->getRight()->print_gtk_ric(); } iter2=aux; //riprende dopo aver appeso i rami destri, e termina con i rami sinistri *************** *** 451,455 **** { msg=NULL; ! msg = g_strdup_printf ("(son of: %d) Left Value: %d", getValue(),getLeft()->getValue()); gtk_tree_store_append (GTK_TREE_STORE (store), &iter1,&iter2); gtk_tree_store_set (GTK_TREE_STORE (store), &iter1, 0, msg, -1); --- 442,446 ---- { msg=NULL; ! msg = g_strdup_printf ("(son of: %d) Left Value: %d", (int)getValue(),(int)getLeft()->getValue()); gtk_tree_store_append (GTK_TREE_STORE (store), &iter1,&iter2); gtk_tree_store_set (GTK_TREE_STORE (store), &iter1, 0, msg, -1); *************** *** 457,461 **** iter2=iter1; ! getLeft()->print_gtk_ric(); } --- 448,452 ---- iter2=iter1; ! this->getLeft()->print_gtk_ric(); } *************** *** 463,467 **** } - GtkWidget* Bst::print_best_look() { --- 454,457 ---- Index: avl.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/avl.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** avl.cpp 16 Sep 2004 17:51:16 -0000 1.18 --- avl.cpp 17 Sep 2004 10:41:17 -0000 1.19 *************** *** 87,91 **** sprintf(fullname,"BST Tree Visualization after the %s of value %d",operation,value); nodelist=aux_bst->print_best_look(); ! temp_node_list=aux_avl->print_best_look(); } else return; --- 87,91 ---- sprintf(fullname,"BST Tree Visualization after the %s of value %d",operation,value); nodelist=aux_bst->print_best_look(); ! temp_node_list=aux_bst->print_best_look(); } else return; *************** *** 105,114 **** gtk_widget_show (temp_node_list); gtk_widget_show (popup_window); - } void test_single_operation() { ! GtkWidget* dialog; switch(choice) { case 2: --- 105,116 ---- gtk_widget_show (temp_node_list); gtk_widget_show (popup_window); } void test_single_operation() { ! ! int value=0; GtkWidget* dialog; + value=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3)); + switch(choice) { case 2: *************** *** 126,135 **** else { if (insert) { ! aux_bst->insert(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); ! popup_window(1,"insertion", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); } else { ! aux_bst->erase(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); ! popup_window(1,"deletion", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); } } --- 128,143 ---- else { if (insert) { ! aux_bst->insert(value); ! popup_window(1,"insertion",value ); } else { ! if (aux_bst->nodes() <2) { ! dialog=gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "You can't delete, that's onlt one node left in the BST tree!"); ! gtk_dialog_run (GTK_DIALOG(dialog)); ! gtk_widget_destroy (dialog);} ! else { ! aux_bst->erase(value); ! popup_window(1,"deletion", value); ! } } } *************** *** 145,158 **** else { if (insert) { ! aux_avl=aux_avl->insert(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); ! popup_window(0,"insertion", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); } else { ! aux_avl=aux_avl->erase(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); ! popup_window(0,"deletion", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton3))); ! } ! } break; default:; } --- 153,173 ---- else { if (insert) { ! aux_avl=aux_avl->insert(value); ! popup_window(0,"insertion", value); } else { ! if (aux_avl->nodes() <2) { ! dialog=gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "You can't delete, that's only one node left in the AVL tree!"); ! gtk_dialog_run (GTK_DIALOG(dialog)); ! gtk_widget_destroy (dialog); ! } ! else { ! aux_avl=aux_avl->erase(value); ! popup_window(0,"deletion", value); ! } ! } } break; + default:; } |