9 /* Single linked circular lists with queue represented as pointer to rear */
12 * Initialize empty queue
20 * Insert element into the queue
22 stack push(stack q, selem e)
26 p = (stack) ballocate(sizeof(struct queuelem));
30 /* the lonely element of the queue */
34 } else {/* insert at rear */
42 * Get first element of the queue
47 fprintf(stderr, "getting first element from empty queue\n");
54 * Remove front element from the queue
56 queue qremove(queue q)
61 fprintf(stderr, "removing first element from empty queue\n");
65 q->next = q->next->next;
66 /* removing last element of the queue */
74 * Delete arbitrary element
76 queue qdelete(queue q, qelem e)
86 while (p->elem != e) {
104 * Remove front and insert at rear
106 queue qrotate(queue q)
109 fprintf(stderr, "rotating empty queue\n");