From e20e4f550ae373414d9bc106b1615a5c5896c9c4 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 18 Jul 2024 19:39:44 +0200 Subject: Added pre-computation of short h48 positions --- test/112_h48map/h48map_tests.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'test/112_h48map') diff --git a/test/112_h48map/h48map_tests.c b/test/112_h48map/h48map_tests.c index ce8f657..d70bc3a 100644 --- a/test/112_h48map/h48map_tests.c +++ b/test/112_h48map/h48map_tests.c @@ -1,11 +1,12 @@ #include "../test.h" #define MAP_KEYSHIFT UINT64_C(40) +#define MAXPOS 1000 typedef struct { uint64_t n; uint64_t capacity; - uint64_t mod; + uint64_t randomizer; uint64_t *table; } h48map_t; @@ -15,9 +16,7 @@ typedef struct { } kvpair_t; void h48map_create(h48map_t *, uint64_t, uint64_t); -void h48map_clear(h48map_t *); void h48map_destroy(h48map_t *); -uint64_t h48map_lookup(h48map_t *, uint64_t); void h48map_insertmin(h48map_t *, uint64_t, uint64_t); uint64_t h48map_value(h48map_t *, uint64_t); kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); @@ -40,28 +39,26 @@ uint64_t readl(void) { void run(void) { h48map_t map; - uint64_t n, i, j, capacity, mod, x, y, v; - kvpair_t kv, *a, *b; + uint64_t n, i, j, capacity, randomizer, x, y, v; + kvpair_t kv, a[MAXPOS], b[MAXPOS]; capacity = readl(); - mod = readl(); + randomizer = readl(); n = readl(); - a = malloc(n * sizeof(kvpair_t)); - b = malloc(n * sizeof(kvpair_t)); for (i = 0; i < n; i++) { x = readl(); y = readl(); a[i] = (kvpair_t) { .key = x, .val = y }; } - h48map_create(&map, capacity, mod); + h48map_create(&map, capacity, randomizer); for (i = 0; i < n; i++) h48map_insertmin(&map, a[i].key, a[i].val); i = 0; for (kv = h48map_nextkvpair(&map, &i), j = 0; - i != map.capacity; + i != map.capacity && j < MAXPOS; kv = h48map_nextkvpair(&map, &i) ) { b[j++] = kv; @@ -83,6 +80,4 @@ void run(void) { } h48map_destroy(&map); - free(a); - free(b); } -- cgit v1.3