2025-01-18 17:24:36 +03:00
|
|
|
#ifndef BH_HASHMAP_H
|
|
|
|
|
#define BH_HASHMAP_H
|
|
|
|
|
|
|
|
|
|
|
2025-02-02 21:40:31 +03:00
|
|
|
#include "Common.h"
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
typedef struct BH_Hashmap BH_Hashmap;
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
BH_Hashmap *BH_HashmapNew(BH_EqualCallback equal,
|
|
|
|
|
BH_HashCallback hash);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void BH_HashmapFree(BH_Hashmap *hashmap);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void BH_HashmapClear(BH_Hashmap *hashmap);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
int BH_HashmapReserve(BH_Hashmap *hashmap,
|
|
|
|
|
size_t size);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
int BH_HashmapInsert(BH_Hashmap *hashmap,
|
|
|
|
|
void *key,
|
|
|
|
|
void *value);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void BH_HashmapRemove(BH_Hashmap *hashmap,
|
|
|
|
|
void *key);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
int BH_HashmapAt(BH_Hashmap *hashmap,
|
|
|
|
|
void *key,
|
|
|
|
|
void **value);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
int BH_HashmapEmpty(BH_Hashmap *hashmap);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
size_t BH_HashmapSize(BH_Hashmap *hashmap);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
size_t BH_HashmapCapacity(BH_Hashmap *hashmap);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
float BH_HashmapFactor(BH_Hashmap *hashmap);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void BH_HashmapSetFactor(BH_Hashmap *hashmap,
|
|
|
|
|
float factor);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void *BH_HashmapIterAt(BH_Hashmap *hashmap,
|
|
|
|
|
void *key);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void *BH_HashmapIterNext(BH_Hashmap *hashmap,
|
|
|
|
|
void *iter);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void BH_HashmapIterRemove(BH_Hashmap *hashmap,
|
|
|
|
|
void *iter);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void *BH_HashmapIterKey(void *iter);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
2025-06-21 20:12:15 +03:00
|
|
|
|
2025-01-30 13:53:26 +03:00
|
|
|
void *BH_HashmapIterValue(void *iter);
|
2025-01-18 17:24:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* BH_HASHMAP_H */
|