Update of /cvsroot/avl/avl/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685/src
Modified Files:
Makefile avl.cpp avlt.cpp avlt.h bst.cpp bst.h test.cpp test.h
Log Message:
fixes 2 warning
some code cleaning in avl.cpp
comment and code cleaning in test.*
updated comment and license in all files
updated Makefile for shared build
updated Makfile for debug build
updated relation for Makefile explaination
some check to track seg fault. (still useless)
Index: test.h
===================================================================
RCS file: /cvsroot/avl/avl/src/test.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** test.h 4 Sep 2004 15:30:40 -0000 1.8
--- test.h 6 Sep 2004 13:16:36 -0000 1.9
***************
*** 1,2 ****
--- 1,21 ----
+ /***************************************************************************
+ * Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
#ifndef TEST_H
#define TEST_H
Index: bst.h
===================================================================
RCS file: /cvsroot/avl/avl/src/bst.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** bst.h 4 Aug 2004 15:31:36 -0000 1.4
--- bst.h 6 Sep 2004 13:16:36 -0000 1.5
***************
*** 2,6 ****
* Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
* *
- * *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
--- 2,5 ----
***************
*** 18,21 ****
--- 17,21 ----
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
#ifndef BST_H
#define BST_H
***************
*** 28,34 ****
#include "stdio.h"
- /**
- @authors Patrizio Bassi && Gianlorenzo D'Angelo
- */
class Bst {
--- 28,31 ----
Index: avlt.h
===================================================================
RCS file: /cvsroot/avl/avl/src/avlt.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** avlt.h 21 Jul 2004 16:58:20 -0000 1.7
--- avlt.h 6 Sep 2004 13:16:36 -0000 1.8
***************
*** 1,5 ****
/***************************************************************************
! * Copyright (C) 2004 by Gianlorenzo D'Angelo *
! * jah@notebook0 *
* *
* This program is free software; you can redistribute it and/or modify *
--- 1,4 ----
/***************************************************************************
! * Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
* *
* This program is free software; you can redistribute it and/or modify *
***************
*** 18,21 ****
--- 17,21 ----
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
#ifndef AVLT_H
#define AVLT_H
***************
*** 26,32 ****
using namespace std;
! /**
! @author Gianlorenzo D'Angelo
! */
class Avlt : public Bst
{
--- 26,30 ----
using namespace std;
!
class Avlt : public Bst
{
Index: avlt.cpp
===================================================================
RCS file: /cvsroot/avl/avl/src/avlt.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** avlt.cpp 21 Jul 2004 16:58:20 -0000 1.6
--- avlt.cpp 6 Sep 2004 13:16:36 -0000 1.7
***************
*** 1,5 ****
/***************************************************************************
! * Copyright (C) 2004 by Gianlorenzo D'Angelo *
! * jah@notebook0 *
* *
* This program is free software; you can redistribute it and/or modify *
--- 1,4 ----
/***************************************************************************
! * Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
* *
* This program is free software; you can redistribute it and/or modify *
***************
*** 18,21 ****
--- 17,21 ----
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
#include "avlt.h"
***************
*** 444,448 ****
{
aux = ((Avlt *)getLeft())->getWrongs();
! for(int i=0;i < aux.size();i++)
v.push_back(aux[i]);
}
--- 444,448 ----
{
aux = ((Avlt *)getLeft())->getWrongs();
! for(uint i=0;i < aux.size();i++)
v.push_back(aux[i]);
}
***************
*** 450,454 ****
{
aux = ((Avlt *)getRight())->getWrongs();
! for(int i=0;i<aux.size();i++)
v.push_back(aux[i]);
}
--- 450,454 ----
{
aux = ((Avlt *)getRight())->getWrongs();
! for(uint i=0;i<aux.size();i++)
v.push_back(aux[i]);
}
Index: bst.cpp
===================================================================
RCS file: /cvsroot/avl/avl/src/bst.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** bst.cpp 4 Aug 2004 15:31:36 -0000 1.9
--- bst.cpp 6 Sep 2004 13:16:36 -0000 1.10
***************
*** 2,6 ****
* Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
* *
- * *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
--- 2,5 ----
***************
*** 506,510 ****
//prendo la root e stampo tutto l'albero, appendo il primo valore e poi ricorsivamente tutti gli altri
! root=this->root();
msg = g_strdup_printf ("%d", root->getValue());
gtk_tree_store_append (GTK_TREE_STORE (store), &iter2,&iter1);
--- 505,510 ----
//prendo la root e stampo tutto l'albero, appendo il primo valore e poi ricorsivamente tutti gli altri
! if (this->root() != NULL) root=this->root();
! else root=this;
msg = g_strdup_printf ("%d", root->getValue());
gtk_tree_store_append (GTK_TREE_STORE (store), &iter2,&iter1);
Index: avl.cpp
===================================================================
RCS file: /cvsroot/avl/avl/src/avl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** avl.cpp 4 Sep 2004 15:30:40 -0000 1.9
--- avl.cpp 6 Sep 2004 13:16:36 -0000 1.10
***************
*** 1,5 ****
/***************************************************************************
! * Copyright (C) 2004 by Gianlorenzo D'Angelo *
! * jah@notebook0 *
* *
* This program is free software; you can redistribute it and/or modify *
--- 1,4 ----
/***************************************************************************
! * Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
* *
* This program is free software; you can redistribute it and/or modify *
***************
*** 19,26 ****
***************************************************************************/
- #ifdef HAVE_CONFIG_H
- #include <config.h>
- #endif
-
#include "test.h"
#include <iostream>
--- 18,21 ----
***************
*** 29,79 ****
using namespace std;
- //era un test con la libreria dotneato, ma non mi compila con l'ultima versione
- #if 0
- void print_test(){
-
-
- Agraph_t *g;
- Agnode_t *n, *m;
- Agedge_t *e;
- Agsym_t *a;
-
- /*ma serve? no: initialize devi implementarla tu per ripulire la commandline (se vuoi...)*/
- /* argc = initialize( argc, argv ); */
-
- /*Prende i parametri -T sul tipo file e -o sull'output file: vedi man dot*/
- dotneato_initialize( argc, argv );
-
- /* Crea un semplice digrafo*/
- g = agopen( "g", AGDIGRAPH );
- n = agnode( g, "n" );
- m = agnode( g, "m" );
- e = agedge( g, n, m);
-
- /* Setto l'attributo di rendering: "colore blu"*/
- a = agnodeattr( g, "color", "blue" );
- agxset( n, a->index, "red" );
-
- /* Calcola un layout per il grafo: qui neato*/
- neato_layout( g );
- /* twopi_layout( g );*/
- /* dot_layout( g );*/
-
- /* Scrive il grafo, secondo le opzioni -T ed -o della linea di comando.*/
- dotneato_write( g );
-
- /* Ripulisce le strutture dati usate per creare il layout*/
- neato_cleanup( g );
- /* twopi_cleanup( g );*/
- /* dot_cleanup( g );*/
-
- /* Libera le risorse associate al grafo*/
- agclose( g );
-
-
-
- }
- #endif
-
int main(int argc, char *argv[])
{
--- 24,27 ----
***************
*** 229,233 ****
a.insert(-700);
a.erase(1);*/
! // Bst a(1);
/* for (int i=0;i<500000;i++)
--- 177,181 ----
a.insert(-700);
a.erase(1);*/
! Bst a(1);
/* for (int i=0;i<500000;i++)
***************
*** 241,248 ****
a.erase( aaa );
}*/
! Test t(0,1,100000);
! // a=*(t.getBst());
#ifndef GUI
! //a.print1();
#else
GtkWidget *window;
--- 189,196 ----
a.erase( aaa );
}*/
! Test t(0,10,100000);
! a=*(t.getBst());
#ifndef GUI
! a.print1();
#else
GtkWidget *window;
Index: Makefile
===================================================================
RCS file: /cvsroot/avl/avl/src/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile 4 Aug 2004 15:31:36 -0000 1.5
--- Makefile 6 Sep 2004 13:16:33 -0000 1.6
***************
*** 1,5 ****
! # AVL Project
ifdef gtk_gui
! CC=g++ -O2 -Wall -W `pkg-config gtk+-2.0 --cflags` -DGUI
else
CC=g++ -O2 -Wall -W
--- 1,6 ----
! # AVL Project Makefile
!
ifdef gtk_gui
! CC=g++ -O2 -Wall -W `pkg-config gtk+-2.0 --cflags` -DGUI -g
else
CC=g++ -O2 -Wall -W
***************
*** 31,44 ****
clean:
! rm *.o -f $(BINARY)
shared:
make library
! $(CC) avl.cpp -o $(BINARY) libavl.a
library:
$(CC) -fPIC -c bst.cpp -o bst.o
$(CC) -fPIC -c avlt.cpp -o avlt.o
! $(CC) -shared -Wl,-soname,libavl.a -o libavl.a $(LIBS) -lc
install:
--- 32,46 ----
clean:
! rm *.o -f $(BINARY) libavl.a
shared:
make library
! $(CC) avl.cpp -o $(BINARY) libavl.a test.o
library:
$(CC) -fPIC -c bst.cpp -o bst.o
$(CC) -fPIC -c avlt.cpp -o avlt.o
! $(CC) -fPIC -c test.cpp -o test.o
! $(CC) -shared -Wl,-soname,libavl.a -o libavl.a bst.o avlt.o -lc
install:
***************
*** 46,48 ****
gui:
! make gtk_gui=true
\ No newline at end of file
--- 48,50 ----
gui:
! make gtk_gui=true
Index: test.cpp
===================================================================
RCS file: /cvsroot/avl/avl/src/test.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test.cpp 4 Sep 2004 15:30:40 -0000 1.6
--- test.cpp 6 Sep 2004 13:16:36 -0000 1.7
***************
*** 1,2 ****
--- 1,22 ----
+ /***************************************************************************
+ * Copyright (C) 2004 by Patrizio Bassi && Gianlorenzo D'Angelo *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
#include "test.h"
***************
*** 4,8 ****
//if (avlt) delete avlt;
//if (bst) delete bst;
-
}
--- 24,27 ----
***************
*** 21,25 ****
return bst;
}
!
void Test::Test_Init(int base_limit,int kind=0) {
--- 40,44 ----
return bst;
}
! //inizializza l'albero voluto
void Test::Test_Init(int base_limit,int kind=0) {
***************
*** 55,59 ****
}
!
void Test::Avl_Test(int upper_limit){
--- 74,78 ----
}
! //testa un AVL
void Test::Avl_Test(int upper_limit){
***************
*** 109,113 ****
}
!
void Test::Bst_Test(int upper_limit) {
--- 128,132 ----
}
! //testa un BST
void Test::Bst_Test(int upper_limit) {
***************
*** 162,166 ****
}
!
void Test::comparation(int base_tree_size, int upperbound ) {
--- 181,185 ----
}
! //questo metodo fa un confronto delle prestazioni di un AVL e un BST
void Test::comparation(int base_tree_size, int upperbound ) {
***************
*** 208,211 ****
--- 227,238 ----
Test::Test(int kind, int upperbound, int base_tree_size) {
+ /* 0 testa un albero AVL
+ 1 testa un albero BST
+ 2 testa entrambi e fa un confronto
+
+ upperbound è il numero delle modifiche (ins/canc)
+ base_tree_size è la dimensione dell'albero
+ */
+
tree_dimensions=base_tree_size;
switch (kind){
|