[5717495] | 1 | #include <sys/queue.h> |
---|
| 2 | #include <stdio.h> |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | int main() { |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | struct req { |
---|
[5546f50b] | 21 | int pri, rqr; |
---|
| 22 | LIST_ENTRY(req) by_pri; |
---|
| 23 | LIST_ENTRY(req) by_rqr; |
---|
[5717495] | 24 | }; |
---|
| 25 | |
---|
| 26 | LIST_HEAD(reql, req); |
---|
| 27 | |
---|
[1379c96e] | 28 | struct reql reqs_pri; |
---|
[5717495] | 29 | struct reql reqs_rqr_42; |
---|
| 30 | struct reql reqs_rqr_17; |
---|
| 31 | struct reql reqs_rqr_99; |
---|
| 32 | |
---|
[1379c96e] | 33 | LIST_INIT(&reqs_pri); |
---|
[5717495] | 34 | LIST_INIT(&reqs_rqr_42); |
---|
| 35 | LIST_INIT(&reqs_rqr_17); |
---|
| 36 | LIST_INIT(&reqs_rqr_99); |
---|
| 37 | |
---|
| 38 | struct req |
---|
[5546f50b] | 39 | r42a = {1, 42}, |
---|
| 40 | r42b = {2, 42}, |
---|
| 41 | r17a = {2, 17}, |
---|
| 42 | r17b = {3, 17}, |
---|
| 43 | r17c = {4, 17}, |
---|
| 44 | r99a = {3, 99}; |
---|
[5717495] | 45 | |
---|
[1379c96e] | 46 | LIST_INSERT_HEAD(&reqs_pri, &r17c, by_pri); |
---|
| 47 | LIST_INSERT_HEAD(&reqs_pri, &r99a, by_pri); |
---|
| 48 | LIST_INSERT_HEAD(&reqs_pri, &r17b, by_pri); |
---|
| 49 | LIST_INSERT_HEAD(&reqs_pri, &r42b, by_pri); |
---|
| 50 | LIST_INSERT_HEAD(&reqs_pri, &r17a, by_pri); |
---|
| 51 | LIST_INSERT_HEAD(&reqs_pri, &r42a, by_pri); |
---|
[5717495] | 52 | |
---|
| 53 | LIST_INSERT_HEAD(&reqs_rqr_42, &r42b, by_rqr); |
---|
| 54 | LIST_INSERT_HEAD(&reqs_rqr_42, &r42a, by_rqr); |
---|
| 55 | |
---|
| 56 | LIST_INSERT_HEAD(&reqs_rqr_17, &r17c, by_rqr); |
---|
| 57 | LIST_INSERT_HEAD(&reqs_rqr_17, &r17b, by_rqr); |
---|
| 58 | LIST_INSERT_HEAD(&reqs_rqr_17, &r17a, by_rqr); |
---|
| 59 | |
---|
| 60 | LIST_INSERT_HEAD(&reqs_rqr_99, &r99a, by_rqr); |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | struct req *cur; |
---|
[1379c96e] | 69 | LIST_FOREACH(cur, &reqs_pri, by_pri) |
---|
[5546f50b] | 70 | printf("{%d %d} ", cur->pri, cur->rqr); |
---|
[5717495] | 71 | printf("| "); |
---|
| 72 | LIST_FOREACH(cur, &reqs_rqr_42, by_rqr) |
---|
[5546f50b] | 73 | printf("{%d %d} ", cur->pri, cur->rqr); |
---|
[5717495] | 74 | printf("| "); |
---|
| 75 | LIST_FOREACH(cur, &reqs_rqr_17, by_rqr) |
---|
[5546f50b] | 76 | printf("{%d %d} ", cur->pri, cur->rqr); |
---|
[5717495] | 77 | printf("| "); |
---|
| 78 | LIST_FOREACH(cur, &reqs_rqr_99, by_rqr) |
---|
[5546f50b] | 79 | printf("{%d %d} ", cur->pri, cur->rqr); |
---|
[5717495] | 80 | printf("\n"); |
---|
| 81 | |
---|
[5546f50b] | 82 | } |
---|