bglibs
include
dict.h
1
#ifndef DICT__H__
2
#define DICT__H__
3
4
#include "str.h"
5
#include "uint32.h"
6
7
#define DICT_HASHSTART 5381
8
uint32 dict_hashadd(uint32 h,
const
unsigned
char
* data,
unsigned
long
len);
9
#define dict_hash(BUF,LEN) dict_hashadd(DICT_HASHSTART,BUF,LEN)
10
#define dict_hashstr(STR) dict_hashadd(DICT_HASHSTART,(const unsigned char*)(STR)->s,(STR)->len)
11
12
struct
dict_entry
13
{
14
uint32 hash;
15
str
key;
16
void
* data;
17
};
18
typedef
struct
dict_entry
dict_entry;
19
20
struct
dict
21
{
22
unsigned
size;
23
unsigned
count;
24
dict_entry** table;
25
};
26
typedef
struct
dict
dict;
27
28
extern
int
dict_init(dict*);
29
extern
void
dict_free(dict*,
void
(*free_data)(
void
*));
30
extern
int
dict_add(dict*,
const
str
*,
void
*);
31
extern
dict_entry* dict_get(dict*,
const
str
*);
32
extern
void
dict_foreach(dict* d,
void
(*fn)(
const
str
* key,
void
** dataptr));
33
extern
void
dict_str_free(
void
*);
34
35
extern
int
dict_load_list(dict*,
const
char
* filename,
int
mustexist,
36
int
(*xform)(
str
*));
37
extern
int
dict_load_map(dict*,
const
char
* filename,
int
mustexist,
char
sep,
38
int
(*keyxform)(
str
*),
int
(*valxform)(
str
*));
39
40
#endif
dict
Definition:
dict.h:20
str
Definition:
str.h:30
dict_entry
Definition:
dict.h:12
Generated on Fri Feb 23 2018 10:24:54 for bglibs by
1.8.13