ucx/map.h

changeset 29
bce0d7f2912b
parent 20
db7d9860dbbd
child 30
23bb65cbf7a4
equal deleted inserted replaced
28:1666cbeb1db8 29:bce0d7f2912b
15 typedef struct UcxMap UcxMap; 15 typedef struct UcxMap UcxMap;
16 typedef struct UcxKey UcxKey; 16 typedef struct UcxKey UcxKey;
17 typedef struct UcxMapElement UcxMapElement; 17 typedef struct UcxMapElement UcxMapElement;
18 18
19 struct UcxMap { 19 struct UcxMap {
20 UcxMapElement *map; 20 UcxMapElement **map;
21 size_t size; 21 size_t size;
22 }; 22 };
23 23
24 struct UcxKey { 24 struct UcxKey {
25 void *data; 25 void *data;
33 UcxKey key; 33 UcxKey key;
34 }; 34 };
35 35
36 36
37 UcxMap *ucx_map_new(size_t size); 37 UcxMap *ucx_map_new(size_t size);
38 void ucx_map_free(UcxMap *map);
38 39
39 int ucx_map_put(UcxMap *map, UcxKey key, void *data); 40 int ucx_map_put(UcxMap *map, UcxKey key, void *data);
40 void* ucx_map_get(UcxMap *map, UcxKey key); 41 void* ucx_map_get(UcxMap *map, UcxKey key);
41 42
42 #define ucx_map_sstr_put(m, s, d) ucx_map_put(m, ucx_key(s.ptr, s.length), d) 43 #define ucx_map_sstr_put(m, s, d) ucx_map_put(m, ucx_key(s.ptr, 1+s.length), d)
43 #define ucx_map_cstr_put(m, s, d) ucx_map_put(m, ucx_key(s, strlen(s)), d) 44 #define ucx_map_cstr_put(m, s, d) ucx_map_put(m, ucx_key(s, 1+strlen(s)), d)
44 #define ucx_map_sstr_get(m, s) ucx_map_get(m, ucx_key(s.ptr, s.length)) 45 #define ucx_map_sstr_get(m, s) ucx_map_get(m, ucx_key(s.ptr, 1+s.length))
45 #define ucx_map_cstr_get(m, s) ucx_map_get(m, ucx_key(s, strlen(s))) 46 #define ucx_map_cstr_get(m, s) ucx_map_get(m, ucx_key(s, 1+strlen(s)))
46 47
47 UcxKey ucx_key(void *data, size_t len); 48 UcxKey ucx_key(void *data, size_t len);
48 49
49 int ucx_hash(char *data, size_t len); 50 int ucx_hash(char *data, size_t len);
50 51

mercurial