11 /* Queue management */
12 /* Single linked circular lists with queue represented as pointer to rear */
15 * Initialize empty queue
23 * Insert element into the queue
25 stack push(stack q, selem e)
29 p = (stack) ballocate(sizeof(struct queuelem));
33 /* the lonely element of the queue */
37 } else {/* insert at rear */
45 * Get first element of the queue
50 fprintf(stderr, "getting first element from empty queue\n");
57 * Remove front element from the queue
59 queue qremove(queue q)
64 fprintf(stderr, "removing first element from empty queue\n");
68 q->next = q->next->next;
69 /* removing last element of the queue */
77 * Delete arbitrary element
79 queue qdelete(queue q, qelem e)
89 while (p->elem != e) {
107 * Remove front and insert at rear
109 queue qrotate(queue q)
112 fprintf(stderr, "rotating empty queue\n");