1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#ifndef TUPLE_H
#define TUPLE_H
#include "util.h"
#include "pair.h"
/* This file implements the tuples that we need. A tuple is an array
of arrays of arrays, ..., ad infinitum.
Since the lengths of each layer of the arrays are different, but
uniform within each layer, we store the lengths in an array at the
top level. So there are two kinds of data types: one with an array
of lengths and the other without. */
#define TUP(N) typedef struct PASTER(tuple, N, _s) PASTER(tuple, N,)
#define LTUP(N) typedef struct PASTER(luple, N, _s) PASTER(luple, N,)
#define LONSTRUCT(N) PASTER(luple, N,) *PASTER(new, _luple, N) \
(NUM *len)
#define LESTRUCT(N) void PASTER(destroy_luple, N,) \
(PASTER(luple, N,) *tup)
#define ADDL(N) BOOL PASTER(add_to_luple, N,) \
(PASTER(luple, N,) *lup, PASTER(pair, N,) label, \
NUM val)
#define INDEXL(N) HP_ATTR \
NUM *PASTER(luple, N, _find) \
(PASTER(luple, N,) *lup, PASTER(pair, N,) label)
#define LENTHL(N) P_ATTR NUM *PASTER(luple, N, _len) \
(PASTER(luple, N,) *lup)
typedef struct PASTER(tuple, 1, _s) PASTER(tuple, 1,);
TUP(2);
TUP(3);
TUP(4);
TUP(5);
TUP(6);
LTUP(2);
LTUP(3);
LTUP(4);
LTUP(5);
LTUP(6);
tuple4 *new_tuple4();
LONSTRUCT(2);
LONSTRUCT(3);
LONSTRUCT(4);
LONSTRUCT(5);
LONSTRUCT(6);
void destroy_tuple4(tuple4 tup, NUM *len);
LESTRUCT(2);
LESTRUCT(3);
LESTRUCT(4);
LESTRUCT(5);
LESTRUCT(6);
ADDL(2);
ADDL(3);
ADDL(4);
ADDL(5);
ADDL(6);
H_ATTR BOOL add_to_luple6_pt_2(luple6 *lup, pair2 label);
INDEXL(2);
INDEXL(3);
INDEXL(4);
INDEXL(5);
INDEXL(6);
LENTHL(2);
LENTHL(3);
LENTHL(4);
LENTHL(5);
LENTHL(6);
HP_ATTR BOOL luple3_pf_2(luple3 *lup, pair2 label);
HP_ATTR BOOL luple5_pf_3(luple5 *lup, pair3 label);
HP_ATTR BOOL luple6_pf_2(luple6 *lup, pair2 label);
typedef void (* map_pair3_t) (pair3 label);
typedef void (* map_pair5_t) (pair5 label);
typedef void (* map_pair6_t) (pair6 label);
H_ATTR void luple3_map_2(luple3 *lup, pair2 label, map_pair3_t fn);
/* H_ATTR void tuple5_map_3(tuple5 *lup, pair3 label, map_pair5_t fn); */
H_ATTR void luple5_map_3(luple5 *lup, pair3 label, map_pair5_t fn);
H_ATTR void luple5_free_1(luple5 *lup, NUM label);
/* MAX bounds the last coordinate, i.e. the W coordinate. If -1 then
there is no bound. */
H_ATTR void luple6_map_2(luple6 *lup, pair2 label,
NUM max, map_pair6_t fn);
H_ATTR void luple6_map_5(luple6 *tup, pair5 label, map_pair6_t fn);
#undef LONSTRUCT
#undef LESTRUCT
#undef LTUP
#undef TUP
#undef ADDL
#undef INDEXL
#undef INDEXPL
#undef LENTHL
#endif
|