source: doc/theses/mike_brooks_MMath/programs/lst-features-multidir.run.cfa @ 38e20a80

Last change on this file since 38e20a80 was 5546f50b, checked in by Peter A. Buhr <pabuhr@…>, 8 months ago

more switch to tabs

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include <collections/list.hfa>
2
3
4
5
6int main() {
7
8
9
10
11
12
13
14
15
16
17
18
19
20struct req {
21        int pri, rqr;
22        inline struct by_pri { inline dlink(req); };
23        inline struct by_rqr { inline dlink(req); };
24};
25
26
27
28
29
30// need to spice this case; can't forward declare nested struct
31P9_EMBEDDED_INFUNC(req, req.by_pri)
32P9_EMBEDDED_INFUNC(req, req.by_rqr)
33P9_EMBEDDED_INFUNC(req.by_pri, dlink(req))
34P9_EMBEDDED_INFUNC(req.by_rqr, dlink(req))
35
36
37
38
39
40dlist(req, req.by_pri) reqs_pri_global;
41dlist(req, req.by_rqr) reqs_rqr_42;
42dlist(req, req.by_rqr) reqs_rqr_17;
43dlist(req, req.by_rqr) reqs_rqr_99;
44
45struct req
46        r42a = {1, 42},
47        r42b = {2, 42},
48        r17a = {2, 17},
49        r17b = {3, 17},
50        r17c = {4, 17},
51        r99a = {3, 99};
52
53insert_first(reqs_pri_global, r17c);
54insert_first(reqs_pri_global, r99a);
55insert_first(reqs_pri_global, r17b);
56insert_first(reqs_pri_global, r42b);
57insert_first(reqs_pri_global, r17a);
58insert_first(reqs_pri_global, r42a);
59
60insert_first(reqs_rqr_42, r42b);
61insert_first(reqs_rqr_42, r42a);
62
63insert_first(reqs_rqr_17, r17c);
64insert_first(reqs_rqr_17, r17b);
65insert_first(reqs_rqr_17, r17a);
66
67insert_first(reqs_rqr_99, r99a);
68
69
70
71
72
73
74
75
76with(DLINK_VIA(req, req.by_pri)) {
77        while( req & cur = reqs_pri_global`elems; cur`moveNext )
78                printf("{%d %d} ", cur.pri, cur.rqr);
79        printf("| ");
80}
81
82with(DLINK_VIA(req, req.by_rqr)) {
83        while( req & cur = reqs_rqr_42`elems; cur`moveNext )
84                printf("{%d %d} ", cur.pri, cur.rqr);
85        printf("| ");
86        while( req & cur = reqs_rqr_17`elems; cur`moveNext )
87                printf("{%d %d} ", cur.pri, cur.rqr);
88        printf("| ");
89        while( req & cur = reqs_rqr_99`elems; cur`moveNext )
90                printf("{%d %d} ", cur.pri, cur.rqr);
91        printf("\n");
92}
93
94
95
96
97}
Note: See TracBrowser for help on using the repository browser.