gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8126 - GNUnet/src/applications/dv/module


From: gnunet
Subject: [GNUnet-SVN] r8126 - GNUnet/src/applications/dv/module
Date: Mon, 19 Jan 2009 12:11:05 -0700 (MST)

Author: nevans
Date: 2009-01-19 12:11:05 -0700 (Mon, 19 Jan 2009)
New Revision: 8126

Modified:
   GNUnet/src/applications/dv/module/Makefile.am
   GNUnet/src/applications/dv/module/heap.c
   GNUnet/src/applications/dv/module/heaptest.c
Log:
heaptest and printheap changes

Modified: GNUnet/src/applications/dv/module/Makefile.am
===================================================================
--- GNUnet/src/applications/dv/module/Makefile.am       2009-01-17 20:58:11 UTC 
(rev 8125)
+++ GNUnet/src/applications/dv/module/Makefile.am       2009-01-19 19:11:05 UTC 
(rev 8126)
@@ -9,6 +9,11 @@
 
 plugindir = $(libdir)/GNUnet
 
+noinst_LTLIBRARIES = libheap.la
+
+libheap_la_SOURCES = \
+  dv.c heap.c
+
 plugin_LTLIBRARIES = \
   libgnunetmodule_dv.la
 
@@ -19,3 +24,14 @@
 libgnunetmodule_dv_la_LIBADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)
+  
+check_PROGRAMS = \
+ heaptest
+ 
+TESTS = $(check_PROGRAMS)
+
+heaptest_SOURCES = \
+ heaptest.c
+heaptest_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/applications/dv/module/libheap.la

Modified: GNUnet/src/applications/dv/module/heap.c
===================================================================
--- GNUnet/src/applications/dv/module/heap.c    2009-01-17 20:58:11 UTC (rev 
8125)
+++ GNUnet/src/applications/dv/module/heap.c    2009-01-19 19:11:05 UTC (rev 
8126)
@@ -36,9 +36,15 @@
   if (root->neighbor != NULL)
     fprintf (stdout, "%d\n", root->neighbor->cost);
   if (root->left_child != NULL)
+  {
+       fprintf (stdout, "LEFT of %d\n", root->neighbor->cost);
     printTree (root->left_child);
+  }
   if (root->right_child != NULL)
+  {
+       fprintf (stdout, "RIGHT of %d\n", root->neighbor->cost);
     printTree (root->right_child);
+  }
 }
 
 static struct GNUNET_dv_heap_node *

Modified: GNUnet/src/applications/dv/module/heaptest.c
===================================================================
--- GNUnet/src/applications/dv/module/heaptest.c        2009-01-17 20:58:11 UTC 
(rev 8125)
+++ GNUnet/src/applications/dv/module/heaptest.c        2009-01-19 19:11:05 UTC 
(rev 8126)
@@ -21,18 +21,20 @@
 /**
  * @author Nathan Evans
  * @file applications/dv/module/heaptest.c
- * @brief Definitions of heap operations
+ * @brief Test of heap operations
  */
 
 #include "heap.h"
 #include "dv.h"
 
 
-void
+static int
 iterator_callback (struct GNUNET_dv_neighbor *neighbor,
-                   struct GNUNET_dv_heap *root)
+                   struct GNUNET_dv_heap *root, void *cls)
 {
-  fprintf (stdout, "Node is:%d\n", neighbor->cost);
+  fprintf (stdout, "%d\n", neighbor->cost);
+
+  return GNUNET_OK;
 }
 
 
@@ -66,44 +68,43 @@
   neighbor5->cost = 100;
   neighbor6->cost = 30;
 
-  fprintf (stdout, "Inserting\n");
   GNUNET_DV_Heap_insert (myHeap, neighbor1);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Inserting\n");
   GNUNET_DV_Heap_insert (myHeap, neighbor2);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Inserting\n");
   GNUNET_DV_Heap_insert (myHeap, neighbor3);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Inserting\n");
   GNUNET_DV_Heap_insert (myHeap, neighbor4);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Inserting\n");
   GNUNET_DV_Heap_insert (myHeap, neighbor5);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Inserting\n");
   GNUNET_DV_Heap_insert (myHeap, neighbor6);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Removing\n");
   GNUNET_DV_Heap_removeNode (myHeap, neighbor5);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Removing\n");
   GNUNET_DV_Heap_removeRoot (myHeap);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Updating\n");
   GNUNET_DV_Heap_updateCost (myHeap, neighbor6, 200);
+  fprintf(stdout, "\n");
   printTree (myHeap->root);
 
-  fprintf (stdout, "Iterating\n");
-  GNUNET_DV_Heap_Iterator (iterator_callback, myHeap, myHeap->root);
+  GNUNET_DV_Heap_Iterator (myHeap, myHeap->root, iterator_callback, NULL);
   return 0;
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]