rcx

miscellaneous C library
git clone git://git.rr3.xyz/rcx
Log | Files | Refs | README | LICENSE

decls.h (1257B)


      1 #define SET_SPEC &(RSetTableSpec){ \
      2 		.ksize = sizeof(SET_T), \
      3 		.eq = (RTableEqFunc)(SET_EQ), \
      4 		.hash = (RTableHashFunc)(SET_HASH), \
      5 		.allocz = (RTableAlloczFunc)(SET_ALLOCZ), \
      6 		.free = (RTableFreeFunc)(SET_FREE), \
      7 	}
      8 
      9 static inline UNUSED int
     10 SET_METHOD(init)(SET_NAME *s, usize hint) {
     11 	return r_set_table_init(&s->table, hint, SET_SPEC);
     12 }
     13 
     14 static inline UNUSED void
     15 SET_METHOD(free)(SET_NAME *s) {
     16 	r_set_table_free(&s->table, SET_SPEC);
     17 }
     18 
     19 static inline UNUSED usize
     20 SET_METHOD(len)(SET_NAME *s) {
     21 	return r_set_table_len(&s->table, SET_SPEC);
     22 }
     23 
     24 static inline UNUSED bool
     25 SET_METHOD(has)(SET_NAME *s, SET_T k) {
     26 	u64 h = SET_HASH(&k, s->table.seed, sizeof(SET_T));
     27 	void *vp;
     28 	return r_set_table_acc(&s->table, &vp, &k, h, SET_SPEC) > 0;
     29 }
     30 
     31 static inline UNUSED int
     32 SET_METHOD(put)(SET_NAME *s, SET_T k) {
     33 	u64 h = SET_HASH(&k, s->table.seed, sizeof(SET_T));
     34 	void *vp;
     35 	return r_set_table_ins(&s->table, &vp, &k, h, SET_SPEC);
     36 }
     37 
     38 static inline UNUSED bool
     39 SET_METHOD(del)(SET_NAME *s, SET_T k) {
     40 	u64 h = SET_HASH(&k, s->table.seed, sizeof(SET_T));
     41 	void *vp;
     42 	return r_set_table_del(&s->table, &vp, &k, h, SET_SPEC) > 0;
     43 }
     44 
     45 static inline UNUSED void
     46 SET_METHOD(clr)(SET_NAME *s) {
     47 	r_set_table_clr(&s->table, SET_SPEC);
     48 }
     49 
     50 #undef SET_SPEC