aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-10-20 07:23:56 +0000
committerChristian Grothoff <christian@grothoff.org>2009-10-20 07:23:56 +0000
commit4b552398216ae6fd2587cce5d4ab5b2fed141f4e (patch)
tree634c83030c5d7271fd32194a2ae62b306f8e30d7 /src
parent2c784744bc7a15956c7ee766b5914559279ee83f (diff)
downloadgnunet-4b552398216ae6fd2587cce5d4ab5b2fed141f4e.tar.gz
gnunet-4b552398216ae6fd2587cce5d4ab5b2fed141f4e.zip
remove get_random from API
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_container_lib.h16
-rw-r--r--src/util/container_multihashmap.c30
-rw-r--r--src/util/test_container_multihashmap.c2
3 files changed, 0 insertions, 48 deletions
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
633 it, void *it_cls); 633 it, void *it_cls);
634 634
635 635
636/**
637 * Returns the stored value of a random non-null entry in the hash
638 * table. Returns only the first value, does not go inside bucket
639 * linked list (yet). Runs with a worst case time of N, so it's not
640 * efficient in any way shape or form!!!!.
641 *
642 * @param map the map
643 * @return value associated with a random key
644 */
645void *GNUNET_CONTAINER_multihashmap_get_random (const struct
646 GNUNET_CONTAINER_MultiHashMap
647 *map);
648
649
650
651
652/* ******************** doubly-linked list *************** */ 636/* ******************** doubly-linked list *************** */
653 637
654/** 638/**
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
451} 451}
452 452
453 453
454/**
455 * Returns the stored value of a random non-null entry in the hash
456 * table. Returns only the first value, does not go inside bucket
457 * linked list (yet). Runs with a worst case time of N, so it's not
458 * efficient in any way shape or form!!!!.
459 *
460 * @param map the map
461 * @return value associated with a random key
462 */
463void *
464GNUNET_CONTAINER_multihashmap_get_random (const struct
465 GNUNET_CONTAINER_MultiHashMap *map)
466{
467 unsigned int rand;
468 struct MapEntry *e;
469
470 if (map->size == 0)
471 return NULL;
472 while (1)
473 {
474 rand =
475 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
476 map->map_length);
477 if (NULL != (e = map->map[rand]))
478 return e->value;
479 }
480 return e->value;
481}
482
483
484/* end of container_multihashmap.c */ 454/* 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)
84 CHECK (0 == 84 CHECK (0 ==
85 GNUNET_CONTAINER_multihashmap_get_multiple (m, &k2, NULL, NULL)); 85 GNUNET_CONTAINER_multihashmap_get_multiple (m, &k2, NULL, NULL));
86 CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); 86 CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL));
87 r = GNUNET_CONTAINER_multihashmap_get_random (m);
88 CHECK (0 == strcmp (r, "v1") || 0 == strcmp (r, "v2"));
89 CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1)); 87 CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1));
90 for (j = 0; j < 1024; j++) 88 for (j = 0; j < 1024; j++)
91 CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, 89 CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m,