RPA Toolkit
1bf5a518216dfdb430b3c0cf53c0d924fcfeb669
[rpatk.git] / rlib / rmap.h
1 #ifndef _RMAP_H_
2 #define _RMAP_H_
3
4 #include "rcarray.h"
5 #include "rhash.h"
6 #include "rlist.h"
7 #include "rstring.h"
8 #include "robject.h"
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14
15 #define r_map_hashsize(__m__) (1 << (__m__)->nbits)
16 #define r_map_hashmask(__m__) (r_map_hashsize(__m__) - 1)
17
18 typedef struct rmap_s {
19         robject_t obj;
20         ruint nbits;
21         ruint elt_size;
22         rcarray_t *data;
23         rlist_t *hash;
24         rlist_t active;
25         rlist_t inactive;
26 } rmap_t;
27
28
29 rmap_t *r_map_create(ruint elt_size, ruint nbits);
30 void r_map_destroy(rmap_t *array);
31 rlong r_map_lookup(rmap_t *map, rlong current, const rchar *name, rsize_t namesize);
32 rlong r_map_lookup_s(rmap_t *map, rlong current, const rchar *name);
33 rlong r_map_taillookup(rmap_t *map, rlong current, const rchar *name, rsize_t namesize);
34 rlong r_map_taillookup_s(rmap_t *map, rlong current, const rchar *name);
35 rlong r_map_add(rmap_t *map, const rchar *name, rsize_t namesize, rconstpointer pval);
36 rlong r_map_add_s(rmap_t *map, const rchar *name, rconstpointer pval);
37 rlong r_map_setvalue(rmap_t *map, rlong index, rconstpointer pval);
38 const rchar *r_map_key(rmap_t *map, rulong index);
39 rpointer r_map_value(rmap_t *map, rulong index);
40 rint r_map_delete(rmap_t *map, rulong index);
41
42 rlong r_map_first(rmap_t *map);
43 rlong r_map_last(rmap_t *map);
44 rlong r_map_next(rmap_t *map, rlong current);
45 rlong r_map_prev(rmap_t *map, rlong current);
46
47
48 #ifdef __cplusplus
49 }
50 #endif
51
52 #endif /* _RMAP_H_ */