//queueTest.c //Author: John T. Rine //Date: November 3, 2011 #include"queue.h" int main(int argc, char **argv) { int i, data; node *head, *tail, *temp, *copyHead, *copyTail; head = tail = temp = copyHead = copyTail = NULL; printf("Head is = 0x%x; Tail is = 0x%x\n", head, tail); printf("\nCreating a fixed size queue of 10 nodes...\n"); createFixedQueue(&head, &tail, 10); printf("\nHead is = 0x%x; Tail is = 0x%x\n", head, tail); printf("\nSize of the list is: %d\n", listQueueSizeTail(tail)); i = 10; temp = tail; while(temp != NULL) { temp->data = i; i--; temp = temp->prev; } if(isEmptyTail(tail)) printf("\nQueue is empty!\n"); else printf("\nQueue is not empty!\n"); temp = tail; while(temp != NULL) { printf("\nThis node contains %d\n", temp->data); temp = temp->prev; } printf("\nMaking a copy of the queue...\n"); copyQueue(head, ©Head, ©Tail); printf("\nDestroying the first Queue...\n"); destroyFixedQueueTail(&head, &tail); if(isEmptyTail(tail)) printf("\nQueue is empty!\n"); else printf("\nQueue is not empty!\n"); printf("\nHead is = 0x%x; Tail is = 0x%x\n", head, tail); printf("\nPrinting values of copy of queue...\n"); temp = copyTail; while(temp != NULL) { printf("\nThis node contains %d\n", temp->data); temp = temp->prev; } if(isEmptyTail(copyTail)) printf("\nCopy of queue is empty!\n"); else printf("\nCopy of queue is not empty!\n"); printf("\nDestroying copy of the queue...\n"); destroyFixedQueueTail(©Head, ©Tail); if(isEmptyTail(copyTail)) printf("\nCopy of queue is empty!\n"); else printf("\nCopy of queue is not empty!\n"); printf("\nStarting a new queue using enqueue and a dequeue...\n"); printf("\nEnter the number of data to push onto the queue...\n"); scanf("%d", &i); int ii; ii = i; head = tail = NULL; for(;i > 0; i--) { printf("\nEnter the value to be pushed onto the queue...\n"); scanf("%d", &data); enQueue(&head, &tail, data); } for(;ii > 0; ii--) { printf("Data = %d\n", deQueue(&head, &tail)); } getchar(); }