diff options
Diffstat (limited to 'src/solvers/h48/map.h')
| -rw-r--r-- | src/solvers/h48/map.h | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index e6903ce..7718794 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -1,16 +1,13 @@ | |||
| 1 | /* Type definitions and macros are in a separate file for easier testing */ | 1 | STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t); |
| 2 | #include "map_types_macros.h" | 2 | STATIC void h48map_clear(h48map_t [static 1]); |
| 3 | 3 | STATIC void h48map_destroy(h48map_t [static 1]); | |
| 4 | STATIC void h48map_create(h48map_t *, uint64_t, uint64_t); | 4 | STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t); |
| 5 | STATIC void h48map_clear(h48map_t *); | 5 | STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); |
| 6 | STATIC void h48map_destroy(h48map_t *); | 6 | STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t); |
| 7 | STATIC uint64_t h48map_lookup(h48map_t *, uint64_t); | 7 | STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); |
| 8 | STATIC void h48map_insertmin(h48map_t *, uint64_t, uint64_t); | ||
| 9 | STATIC uint64_t h48map_value(h48map_t *, uint64_t); | ||
| 10 | STATIC kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); | ||
| 11 | 8 | ||
| 12 | STATIC void | 9 | STATIC void |
| 13 | h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) | 10 | h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) |
| 14 | { | 11 | { |
| 15 | map->capacity = capacity; | 12 | map->capacity = capacity; |
| 16 | map->randomizer = randomizer; | 13 | map->randomizer = randomizer; |
| @@ -20,20 +17,20 @@ h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) | |||
| 20 | } | 17 | } |
| 21 | 18 | ||
| 22 | STATIC void | 19 | STATIC void |
| 23 | h48map_clear(h48map_t *map) | 20 | h48map_clear(h48map_t map[static 1]) |
| 24 | { | 21 | { |
| 25 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); | 22 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); |
| 26 | map->n = 0; | 23 | map->n = 0; |
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | STATIC void | 26 | STATIC void |
| 30 | h48map_destroy(h48map_t *map) | 27 | h48map_destroy(h48map_t map[static 1]) |
| 31 | { | 28 | { |
| 32 | free(map->table); | 29 | free(map->table); |
| 33 | } | 30 | } |
| 34 | 31 | ||
| 35 | STATIC_INLINE uint64_t | 32 | STATIC_INLINE uint64_t |
| 36 | h48map_lookup(h48map_t *map, uint64_t x) | 33 | h48map_lookup(h48map_t map[static 1], uint64_t x) |
| 37 | { | 34 | { |
| 38 | uint64_t hash, i; | 35 | uint64_t hash, i; |
| 39 | 36 | ||
| @@ -47,7 +44,7 @@ h48map_lookup(h48map_t *map, uint64_t x) | |||
| 47 | } | 44 | } |
| 48 | 45 | ||
| 49 | STATIC_INLINE void | 46 | STATIC_INLINE void |
| 50 | h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) | 47 | h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) |
| 51 | { | 48 | { |
| 52 | uint64_t i, oldval, min; | 49 | uint64_t i, oldval, min; |
| 53 | 50 | ||
| @@ -60,13 +57,13 @@ h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) | |||
| 60 | } | 57 | } |
| 61 | 58 | ||
| 62 | STATIC_INLINE uint64_t | 59 | STATIC_INLINE uint64_t |
| 63 | h48map_value(h48map_t *map, uint64_t key) | 60 | h48map_value(h48map_t map[static 1], uint64_t key) |
| 64 | { | 61 | { |
| 65 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; | 62 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; |
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | STATIC kvpair_t | 65 | STATIC kvpair_t |
| 69 | h48map_nextkvpair(h48map_t *map, uint64_t *p) | 66 | h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1]) |
| 70 | { | 67 | { |
| 71 | kvpair_t kv; | 68 | kvpair_t kv; |
| 72 | uint64_t pair; | 69 | uint64_t pair; |
