gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9008 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r9008 - in gnunet/src: include util
Date: Tue, 22 Sep 2009 11:33:51 -0600

Author: grothoff
Date: 2009-09-22 11:33:51 -0600 (Tue, 22 Sep 2009)
New Revision: 9008

Modified:
   gnunet/src/include/gnunet_container_lib.h
   gnunet/src/util/container_heap.c
Log:
heap fixes

Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h   2009-09-22 17:33:31 UTC (rev 
9007)
+++ gnunet/src/include/gnunet_container_lib.h   2009-09-22 17:33:51 UTC (rev 
9008)
@@ -689,8 +689,9 @@
 /**
  * Cost by which elements in a heap can be ordered.
  */
-typedef unsigned int GNUNET_CONTAINER_HeapCost;
+typedef uint64_t GNUNET_CONTAINER_HeapCost;
 
+
 /*
  * Heap type, either max or min.  Hopefully makes the
  * implementation more useful.
@@ -708,6 +709,7 @@
   GNUNET_CONTAINER_HEAP_ORDER_MIN
 };
 
+
 /**
  * Handle to a Heap.
  */
@@ -723,6 +725,7 @@
                                                             
GNUNET_CONTAINER_HeapOrder
                                                             type);
 
+
 /**
  * Free a heap
  *
@@ -730,6 +733,7 @@
  */
 void GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *h);
 
+
 /**
  * Function called on elements of a heap.
  *
@@ -742,6 +746,8 @@
 typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls,
                                               void *element,
                                               GNUNET_CONTAINER_HeapCost cost);
+
+
 /**
  * Iterate over all entries in the map.
  *
@@ -756,6 +762,7 @@
                                    void *iterator_cls);
 
 
+
 /**
  * Inserts a new item into the heap, item is always neighbor now.
  * @param heap the heap
@@ -764,6 +771,7 @@
 GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap,
                               void *element, GNUNET_CONTAINER_HeapCost cost);
 
+
 /**
  * Removes root of the tree, is remove max if a max heap and remove min
  * if a min heap, returns the data stored at the node.
@@ -773,6 +781,7 @@
  */
 void *GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap);
 
+
 /**
  * Returns element stored at root of tree, doesn't effect anything
  *
@@ -781,6 +790,7 @@
  */
 void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap);
 
+
 /**
  * Removes any node from the tree based on the neighbor given, does
  * not traverse the tree (backpointers) but may take more time due to
@@ -790,6 +800,7 @@
 void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap,
                                          void *element);
 
+
 /**
  * Updates the cost of any node in the tree
  *
@@ -803,6 +814,7 @@
                                    void *element,
                                    GNUNET_CONTAINER_HeapCost new_cost);
 
+
 /**
  * Random walk of the tree, returns the data stored at the next random node
  * in the walk.  Calls callee with the data, or NULL if the tree is empty
@@ -814,6 +826,7 @@
 void *GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap
                                            *heap);
 
+
 /**
  * Returns the current size of the heap
  *
@@ -824,6 +837,7 @@
 GNUNET_CONTAINER_heap_get_size (struct GNUNET_CONTAINER_Heap *heap);
 
 
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/util/container_heap.c
===================================================================
--- gnunet/src/util/container_heap.c    2009-09-22 17:33:31 UTC (rev 9007)
+++ gnunet/src/util/container_heap.c    2009-09-22 17:33:51 UTC (rev 9008)
@@ -72,18 +72,31 @@
 
 };
 
+
+/**
+ * Returns element stored at root of tree, doesn't effect anything
+ *
+ * @param heap the heap
+ * @return NULL if the heap is empty
+ */
+void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap)
+{
+  return heap->root;
+}
+
+
 void
 internal_print (struct GNUNET_CONTAINER_heap_node *root)
 {
-  fprintf (stdout, "%d\n", root->cost);
+  fprintf (stdout, "%llu\n", (unsigned long long) root->cost);
   if (root->left_child != NULL)
     {
-      fprintf (stdout, "LEFT of %d\n", root->cost);
+      fprintf (stdout, "LEFT of %llu\n", (unsigned long long) root->cost);
       internal_print (root->left_child);
     }
   if (root->right_child != NULL)
     {
-      fprintf (stdout, "RIGHT of %d\n", root->cost);
+      fprintf (stdout, "RIGHT of %llu\n", (unsigned long long) root->cost);
       internal_print (root->right_child);
     }
 }





reply via email to

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