remove get_random from API
authorChristian Grothoff <christian@grothoff.org>
Tue, 20 Oct 2009 07:23:56 +0000 (07:23 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 20 Oct 2009 07:23:56 +0000 (07:23 +0000)
src/include/gnunet_container_lib.h
src/util/container_multihashmap.c
src/util/test_container_multihashmap.c

index 97bce967e19dc318ee38d5f7a9309ff8f34221c4..edda98e07ac8ae69bc3327b41033b1636243bbea 100644 (file)
@@ -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 *************** */
 
 /**
index ac19052010c28d8e5735c2fe30e70f0ec58cc86d..38cd65753899cc8b717d5708ee794058bf3bfa7e 100644 (file)
@@ -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 */
index e92ab49ba133e4101954db1e54fd463744fb6a6d..34d24a8faff626bdb2cff2a04a822c7e2cea94fe 100644 (file)
@@ -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,