object: hashmap: implement integer-based hashmap keys

rather than always interpreting a b_hashmap_key as a buffer to be hashed,
b_hashmap can now be told to consider the value of the key_data pointer itself
as the key, treating it as a buffer of size sizeof(void*).
This commit is contained in:
2025-09-22 10:48:05 +01:00
parent d9041cda3f
commit b7da91ac93
2 changed files with 54 additions and 19 deletions

View File

@@ -7,6 +7,7 @@
#include <blue/core/status.h>
#include <blue/object/object.h>
#include <blue/object/type.h>
#include <stddef.h>
#define B_HASHMAP(p) ((b_hashmap *)(p))
@@ -38,7 +39,12 @@ typedef struct b_hashmap b_hashmap;
typedef void (*b_hashmap_key_destructor)(void *);
typedef void (*b_hashmap_value_destructor)(void *);
typedef enum b_hashmap_key_flags {
B_HASHMAP_KEY_F_INTVALUE = 0x01u,
} b_hashmap_key_flags;
typedef struct b_hashmap_key {
b_hashmap_key_flags key_flags;
const void *key_data;
size_t key_size;
} b_hashmap_key;