adding random_heap function definition in case I add it another way
authorNathan S. Evans <evans@in.tum.de>
Fri, 12 Mar 2010 17:32:10 +0000 (17:32 +0000)
committerNathan S. Evans <evans@in.tum.de>
Fri, 12 Mar 2010 17:32:10 +0000 (17:32 +0000)
src/include/gnunet_container_lib.h

index 204d3d6ab293a86b22a0d7b25b903b588db96579..bec0405969c439906c07cb1d5a0732e30cac2cb7 100644 (file)
@@ -828,6 +828,21 @@ GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap,
                               void *iterator_cls);
 
 
+/**
+ * Return a *uniform* random element from the heap.  Choose a random
+ * number between 0 and heap size and then walk directly to it.
+ * This cost can be between 0 and n, amortized cost of logN.
+ *
+ * @param heap heap to choose random element from
+ * @param max how many nodes from the heap to choose from
+ *
+ * @return data stored at the chosen random node,
+ *         NULL if the heap is empty.
+ *
+ */
+void *
+GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, uint32_t max);
+
 /**
  * Perform a random walk of the tree.  The walk is biased
  * towards elements closer to the root of the tree (since