diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-20 07:23:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-20 07:23:56 +0000 |
commit | 4b552398216ae6fd2587cce5d4ab5b2fed141f4e (patch) | |
tree | 634c83030c5d7271fd32194a2ae62b306f8e30d7 /src/util | |
parent | 2c784744bc7a15956c7ee766b5914559279ee83f (diff) | |
download | gnunet-4b552398216ae6fd2587cce5d4ab5b2fed141f4e.tar.gz gnunet-4b552398216ae6fd2587cce5d4ab5b2fed141f4e.zip |
remove get_random from API
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/container_multihashmap.c | 30 | ||||
-rw-r--r-- | src/util/test_container_multihashmap.c | 2 |
2 files changed, 0 insertions, 32 deletions
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 | */ | ||
463 | void * | ||
464 | GNUNET_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, |