From 4b552398216ae6fd2587cce5d4ab5b2fed141f4e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 20 Oct 2009 07:23:56 +0000 Subject: remove get_random from API --- src/include/gnunet_container_lib.h | 16 ---------------- src/util/container_multihashmap.c | 30 ------------------------------ src/util/test_container_multihashmap.c | 2 -- 3 files changed, 48 deletions(-) (limited to 'src') diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 97bce967e..edda98e07 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h @@ -633,22 +633,6 @@ int GNUNET_CONTAINER_multihashmap_get_multiple (const struct it, void *it_cls); -/** - * Returns the stored value of a random non-null entry in the hash - * table. Returns only the first value, does not go inside bucket - * linked list (yet). Runs with a worst case time of N, so it's not - * efficient in any way shape or form!!!!. - * - * @param map the map - * @return value associated with a random key - */ -void *GNUNET_CONTAINER_multihashmap_get_random (const struct - GNUNET_CONTAINER_MultiHashMap - *map); - - - - /* ******************** doubly-linked list *************** */ /** diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index ac1905201..38cd65753 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c @@ -451,34 +451,4 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct } -/** - * Returns the stored value of a random non-null entry in the hash - * table. Returns only the first value, does not go inside bucket - * linked list (yet). Runs with a worst case time of N, so it's not - * efficient in any way shape or form!!!!. - * - * @param map the map - * @return value associated with a random key - */ -void * -GNUNET_CONTAINER_multihashmap_get_random (const struct - GNUNET_CONTAINER_MultiHashMap *map) -{ - unsigned int rand; - struct MapEntry *e; - - if (map->size == 0) - return NULL; - while (1) - { - rand = - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - map->map_length); - if (NULL != (e = map->map[rand])) - return e->value; - } - return e->value; -} - - /* end of container_multihashmap.c */ diff --git a/src/util/test_container_multihashmap.c b/src/util/test_container_multihashmap.c index e92ab49ba..34d24a8fa 100644 --- a/src/util/test_container_multihashmap.c +++ b/src/util/test_container_multihashmap.c @@ -84,8 +84,6 @@ testMap (int i) CHECK (0 == GNUNET_CONTAINER_multihashmap_get_multiple (m, &k2, NULL, NULL)); CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); - r = GNUNET_CONTAINER_multihashmap_get_random (m); - CHECK (0 == strcmp (r, "v1") || 0 == strcmp (r, "v2")); CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1)); for (j = 0; j < 1024; j++) CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, -- cgit v1.2.3