RPA Toolkit
added long, double key support for the rmap_t.
[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_lookup_d(rmap_t *map, rlong current, double name);
36 rlong r_map_lookup_l(rmap_t *map, rlong current, long name);
37 rlong r_map_add(rmap_t *map, const rchar *name, rsize_t namesize, rconstpointer pval);
38 rlong r_map_add_s(rmap_t *map, const rchar *name, rconstpointer pval);
39 rlong r_map_add_d(rmap_t *map, double name, rconstpointer pval);
40 rlong r_map_add_l(rmap_t *map, long name, rconstpointer pval);
41 rlong r_map_setvalue(rmap_t *map, rlong index, rconstpointer pval);
42 const rchar *r_map_key(rmap_t *map, rulong index);
43 rpointer r_map_value(rmap_t *map, rulong index);
44 rint r_map_delete(rmap_t *map, rulong index);
45
46 rlong r_map_first(rmap_t *map);
47 rlong r_map_last(rmap_t *map);
48 rlong r_map_next(rmap_t *map, rlong current);
49 rlong r_map_prev(rmap_t *map, rlong current);
50
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif /* _RMAP_H_ */