58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
#ifndef _HEXAGRAM_DICT_H
|
|
#define _HEXAGRAM_DICT_H
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
|
|
#define HEXAGRAM_DICT_BUCKET_SLOTS 16
|
|
#define HEXAGRAM_DICT_BUCKET_DEPTH 7
|
|
|
|
typedef struct _hexagram_dict_slot {
|
|
uint32_t hash;
|
|
void *key;
|
|
void *value;
|
|
|
|
struct _hexagram_dict_slot *next_bucket;
|
|
} hexagram_dict_slot;
|
|
|
|
typedef struct _hexagram_dict_bucket {
|
|
hexagram_dict_slot slots[16];
|
|
} hexagram_dict_bucket;
|
|
|
|
typedef struct _hexagram_dict {
|
|
hexagram_dict_bucket *bucket;
|
|
} hexagram_dict;
|
|
|
|
hexagram_dict *hexagram_dict_new();
|
|
|
|
void hexagram_dict_destroy(hexagram_dict *dict);
|
|
|
|
typedef int (hexagram_dict_callback)(hexagram_dict *dict,
|
|
hexagram_dict_slot *slot,
|
|
void *ctx);
|
|
|
|
int hexagram_dict_each(hexagram_dict *dict,
|
|
hexagram_dict_callback *callback,
|
|
void *ctx);
|
|
|
|
void *hexagram_dict_get(hexagram_dict *dict, void *key, size_t keysz);
|
|
|
|
void *hexagram_dict_get_s(hexagram_dict *dict, const char *key);
|
|
|
|
int hexagram_dict_delete(hexagram_dict *dict, void *key, size_t keysz);
|
|
|
|
int hexagram_dict_delete_s(hexagram_dict *dict, const char *key);
|
|
|
|
void *hexagram_dict_set_with_hash(hexagram_dict *dict,
|
|
void *key,
|
|
void *value,
|
|
uint32_t hash);
|
|
|
|
void *hexagram_dict_set(hexagram_dict *dict,
|
|
void *key,
|
|
size_t keysz,
|
|
void *value);
|
|
|
|
void *hexagram_dict_set_s(hexagram_dict *dict, const char *key, void *value);
|
|
|
|
#endif /* _HEXAGRAM_DICT_H */
|