[Avl-cvs] avl/src avl.cpp,1.13,1.14 avlt.cpp,1.8,1.9 bst.cpp,1.12,1.13
Brought to you by:
hetfield666,
jah2003
From: Gianlorenzo D\\'A. <ja...@us...> - 2004-09-07 13:03:36
|
Update of /cvsroot/avl/avl/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20647 Modified Files: avl.cpp avlt.cpp bst.cpp Log Message: Index: avlt.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/avlt.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** avlt.cpp 6 Sep 2004 14:12:06 -0000 1.8 --- avlt.cpp 7 Sep 2004 13:03:21 -0000 1.9 *************** *** 177,181 **** else { ! setLeft(new Avlt); getLeft()->setParent(this); getLeft()->setValue(key); --- 177,181 ---- else { ! setLeft(new Avlt()); getLeft()->setParent(this); getLeft()->setValue(key); *************** *** 201,205 **** else { ! setRight(new Avlt); getRight()->setParent(this); getRight()->setValue(key); --- 201,205 ---- else { ! setRight(new Avlt()); getRight()->setParent(this); getRight()->setValue(key); *************** *** 258,262 **** else { ! aux2->setLeft(new Avlt); aux2->getLeft()->setParent(aux2); aux2->getLeft()->setValue(key); --- 258,262 ---- else { ! aux2->setLeft(new Avlt()); aux2->getLeft()->setParent(aux2); aux2->getLeft()->setValue(key); *************** *** 279,283 **** else { ! aux2->setRight(new Avlt); aux2->getRight()->setParent(aux2); aux2->getRight()->setValue(key); --- 279,283 ---- else { ! aux2->setRight(new Avlt()); aux2->getRight()->setParent(aux2); aux2->getRight()->setValue(key); Index: bst.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/bst.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** bst.cpp 7 Sep 2004 11:53:10 -0000 1.12 --- bst.cpp 7 Sep 2004 13:03:21 -0000 1.13 *************** *** 22,32 **** Bst::Bst() { ! Bst(0); } Bst::Bst(int val) { ! value = val; ! left = right = parent = NULL; } --- 22,38 ---- Bst::Bst() { ! //Bst(0); ! setValue(0); ! setLeft(NULL); ! setRight(NULL); ! setParent(NULL); } Bst::Bst(int val) { ! setValue(val); ! setLeft(NULL); ! setRight(NULL); ! setParent(NULL); } *************** *** 176,186 **** aux1 = this; aux2 = NULL; ! while( aux1 ) //ricerca del nodo ! { if ( key == aux1->getValue() ) return; // se il valore si trova già nell'albero si esce ! aux2 = aux1; //aux2 mantiene il puntatore al nodo al quale si deve appendere il nuovo nodo if ( key < aux1->getValue() ) aux1 = aux1->getLeft(); --- 182,193 ---- aux1 = this; aux2 = NULL; ! while( aux1 ) //ricerca del nodo ! { if ( key == aux1->getValue() ) return; // se il valore si trova già nell'albero si esce ! aux2 = aux1; //aux2 mantiene il puntatore al nodo al quale si deve appendere il nuovo nodo + if ( key < aux1->getValue() ) aux1 = aux1->getLeft(); *************** *** 188,192 **** aux1 = aux1->getRight(); } ! // viene istanziato il nuovo nodo e gli viene assegnato key come valore e aux2 come genitore aux1 = new Bst( key ); --- 195,199 ---- aux1 = aux1->getRight(); } ! // viene istanziato il nuovo nodo e gli viene assegnato key come valore e aux2 come genitore aux1 = new Bst( key ); *************** *** 195,202 **** // il nuovo nodo viene appeso a sinistra o a destra di aux2 in base al suo valore ! if ( key < aux2->getValue() ) ! aux2->setLeft( aux1 ); ! else ! aux2->setRight( aux1 ); } --- 202,210 ---- // il nuovo nodo viene appeso a sinistra o a destra di aux2 in base al suo valore ! if(aux2) ! if ( key < aux2->getValue() ) ! aux2->setLeft( aux1 ); ! else ! aux2->setRight( aux1 ); } Index: avl.cpp =================================================================== RCS file: /cvsroot/avl/avl/src/avl.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** avl.cpp 7 Sep 2004 11:53:10 -0000 1.13 --- avl.cpp 7 Sep 2004 13:03:21 -0000 1.14 *************** *** 25,34 **** void p(){ ! Bst* bst=new Bst(); for (int i=0;i<1500;i++) { ! bst->insert(i); } --- 25,34 ---- void p(){ ! Avlt* av=new Avlt(); for (int i=0;i<1500;i++) { ! av->insert(i); } |