diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-03-12 17:32:10 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-03-12 17:32:10 +0000 |
commit | 5491c6356965f9c20ef64f2c63f7a14989930bf3 (patch) | |
tree | 3aaea35bd6ad67e13b686ad2b4b9b4aed2d3bfd0 /src/include/gnunet_container_lib.h | |
parent | 54ce17ec50827d3a905a3cb182ccd3c18bbd3668 (diff) | |
download | gnunet-5491c6356965f9c20ef64f2c63f7a14989930bf3.tar.gz gnunet-5491c6356965f9c20ef64f2c63f7a14989930bf3.zip |
adding random_heap function definition in case I add it another way
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r-- | src/include/gnunet_container_lib.h | 15 |
1 files changed, 15 insertions, 0 deletions
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 | |||
@@ -829,6 +829,21 @@ GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap, | |||
829 | 829 | ||
830 | 830 | ||
831 | /** | 831 | /** |
832 | * Return a *uniform* random element from the heap. Choose a random | ||
833 | * number between 0 and heap size and then walk directly to it. | ||
834 | * This cost can be between 0 and n, amortized cost of logN. | ||
835 | * | ||
836 | * @param heap heap to choose random element from | ||
837 | * @param max how many nodes from the heap to choose from | ||
838 | * | ||
839 | * @return data stored at the chosen random node, | ||
840 | * NULL if the heap is empty. | ||
841 | * | ||
842 | */ | ||
843 | void * | ||
844 | GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, uint32_t max); | ||
845 | |||
846 | /** | ||
832 | * Perform a random walk of the tree. The walk is biased | 847 | * Perform a random walk of the tree. The walk is biased |
833 | * towards elements closer to the root of the tree (since | 848 | * towards elements closer to the root of the tree (since |
834 | * each walk starts at the root and ends at a random leaf). | 849 | * each walk starts at the root and ends at a random leaf). |