assembly-hashmap 0.1.0

A single-threaded u64→u64 hashmap with x86-64 assembly operations and Rust-side growth.
Documentation
#ifndef HASHMAP_H
#define HASHMAP_H

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct HashMap HashMap;

typedef struct {
    /*
     * status:
     *   0 = key was absent (and insertion operations inserted it)
     *   1 = key was present; value contains the old/current value
     *   2 = insertion needs the caller to rebuild/resize and retry
     */
    uint64_t present;
    uint64_t value;
} hm_option;

/* Create a table that can hold at least `min_items` live entries without
 * exceeding the 7/8 load factor used by hashbrown / std HashMap. */
HashMap *hm_create(size_t min_items);
void hm_destroy(HashMap *map);

size_t hm_len(const HashMap *map);
size_t hm_capacity(const HashMap *map);
void hm_clear(HashMap *map);

/* insert: if `key` was present, overwrite and return the previous value. */
hm_option hm_put(HashMap *map, uint64_t key, uint64_t value);
hm_option hm_get(const HashMap *map, uint64_t key);
hm_option hm_remove(HashMap *map, uint64_t key);
uint64_t hm_contains(const HashMap *map, uint64_t key);

/* One-probe compound operations. */
hm_option hm_put_if_absent(HashMap *map, uint64_t key, uint64_t value);
hm_option hm_get_or_insert(HashMap *map, uint64_t key, uint64_t value);
hm_option hm_replace(HashMap *map, uint64_t key, uint64_t value);

/* Iteration cursor starts at zero. Returns 1 and advances it, or returns 0. */
uint64_t hm_iter_next(const HashMap *map, size_t *cursor, uint64_t *key,
                      uint64_t *value);

#ifdef __cplusplus
}
#endif

#endif