#include #include #include #include "gqueue.h" static void usage(int argc, char **argv) { if (argc != 2) { printf("Usage: %s \n", argv[0]); exit(1); } } void main(int argc, char **argv) { int n; int i; gqueue q; usage(argc, argv); n = atoi(argv[1]); q = gq_create(); for (i = 0; i < n; ++i) { gq_insert(q, (void *)i); } for (gq_go_beginning(q); !gq_at_end(q); gq_go_forward(q)) { printf("%d ", (int) gq_get(q)); } printf("\n"); gq_go_end(q); do { gq_go_backward(q); printf("%d ", (int)gq_get(q)); gq_delete(q); } while (!gq_at_beginning(q)); printf("\n"); assert(gq_empty(q)); gq_destroy(q); } /* output de "test-gqueue 10": 0 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 0 */