From 5491c6356965f9c20ef64f2c63f7a14989930bf3 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Fri, 12 Mar 2010 17:32:10 +0000 Subject: [PATCH] adding random_heap function definition in case I add it another way --- src/include/gnunet_container_lib.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 204d3d6ab..bec040596 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h @@ -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 -- 2.25.1