[5717495] | 1 | #include <containers/list.hfa> |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | int main() { |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | struct 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 |
---|
| 31 | P9_EMBEDDED_INFUNC(req, req.by_pri) |
---|
| 32 | P9_EMBEDDED_INFUNC(req, req.by_rqr) |
---|
| 33 | P9_EMBEDDED_INFUNC(req.by_pri, dlink(req)) |
---|
| 34 | P9_EMBEDDED_INFUNC(req.by_rqr, dlink(req)) |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | dlist(req, req.by_pri) reqs_pri_global; |
---|
| 41 | dlist(req, req.by_rqr) reqs_rqr_42; |
---|
| 42 | dlist(req, req.by_rqr) reqs_rqr_17; |
---|
| 43 | dlist(req, req.by_rqr) reqs_rqr_99; |
---|
| 44 | |
---|
| 45 | struct 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 | |
---|
| 53 | insert_first(reqs_pri_global, r17c); |
---|
| 54 | insert_first(reqs_pri_global, r99a); |
---|
| 55 | insert_first(reqs_pri_global, r17b); |
---|
| 56 | insert_first(reqs_pri_global, r42b); |
---|
| 57 | insert_first(reqs_pri_global, r17a); |
---|
| 58 | insert_first(reqs_pri_global, r42a); |
---|
| 59 | |
---|
| 60 | insert_first(reqs_rqr_42, r42b); |
---|
| 61 | insert_first(reqs_rqr_42, r42a); |
---|
| 62 | |
---|
| 63 | insert_first(reqs_rqr_17, r17c); |
---|
| 64 | insert_first(reqs_rqr_17, r17b); |
---|
| 65 | insert_first(reqs_rqr_17, r17a); |
---|
| 66 | |
---|
| 67 | insert_first(reqs_rqr_99, r99a); |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | with(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 | |
---|
| 82 | with(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 | } |
---|