cu
generic.h
Go to the documentation of this file.
1 #ifndef CU_GENERIC_H_
2 #define CU_GENERIC_H_
3 
9 #define cu_push(x, y) _Generic((x), \
10  vector_t * : vector_push((vector_t *)x, y), \
11  list_t * : list_push_back((list_t *)x, y) \
12  )
13 
14 #define cu_new(x) _Generic((x), \
15  vector_t * : vector_new(), \
16  list_t * : list_new()\
17  )
18 
19 #define cu_clear(x, fn) _Generic((x), \
20  vector_t * : vector_clear((vector_t *)x, fn), \
21  list_t * : list_clear((list_t *)x, fn) \
22  )
23 
24 #define cu_del(x) _Generic((x), \
25  vector_t * : vector_del((vector_t *)x), \
26  list_t * : list_del((list_t *)x) \
27  )
28 
29 #define cu_clear_del(x, fn) _Generic((x), \
30  vector_t * : vector_clear_del((vector_t *)x, fn), \
31  list_t * : list_clear_del((list_t *)x, fn) \
32  )
33 #define cu_len(x) _Generic((x), \
34  vector_t * : vector_len((vector_t *)x), \
35  list_t * : list_len((list_t *)x) \
36  )
37 
38 #define cu_foreach(x, fn) _Generic((x), \
39  vector_t * : vector_foreach((vector_t *)x, fn), \
40  list_t * : list_foreach((list_t *)x, fn) \
41  )
42 
43 #define cu_is_empty(x) _Generic((x), \
44  vector_t * : vector_is_empty((vector_t *)x), \
45  list_t * : list_is_empty((list_t *)x) \
46  )
47 
48 #define cu_find(x, key, pred) _Generic((x), \
49  vector_t * : vector_find((vector_t *)x, key, pred), \
50  list_t * : list_find((list_t *)x, key, pred) \
51  )
52 
53 #define cu_insert(x, index, data) _Generic((x), \
54  vector_t * : vector_insert((vector_t *)x, index, data), \
55  list_t * : list_insert((list_t *) x, index, data) \
56  )
57 
58 #define cu_contains(x, key, pred) _Generic((x), \
59  vector_t * : vector_contains((vector_t *)x, key, pred), \
60  list_t * : list_contains((list_t *)x, key, pred) \
61  )
62 
63 
64 
65 #endif /* ifndef CU_GENERIC_H_ */