home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Journal 1990 - 1995 / CUJ.iso / image90 / 9006t1f4.pcx (.png) < prev    next >
PC Paintbrush Image  |  1996-01-31  |  78KB  |  714x428  |  4-bit (4 colors)
Labels: text | menu | font | screenshot | handwriting | black and white | number
OCR: Queve Implemenation of a queue as a linked data structure If (empty()) Operations supported: Queue is empty, point the queue head and tail place item x at end of queue at the new iten head return item at head of queue qHead = new; dequeue remove next item from front of queue qTail = new; empty return true iff queue is empty Elsc * Data structures *.**** qHead pointer to the head of queue Queue is not empty, insert the item and point oTail pointer to the tail of queue: everything to it qItem quese member structure . qfail->next > new; anItem the item itself - must be proper type next pointer to next item on queue qTail " new: to contain the tyce of items on queue typedef long member; * storing longs on this queue typedef struct iten * remove next item from queue item *next; void dequeue ( ) { member anItem; * head is always next item .3iten; qHead = qHead->next; item *quhead = NULL, * qtail = NULL; If (qHead == NULL} Functions queue is now empty qTail = NULL; * add an item to queue - void enqueue [item x] . [ * Allocate a new item structure item *new; * pointer to new node "return item at head of queue; don't remove new = malloc[sizeof item); member head (} { return (qHead->an]tem) ; * Place the item on the queue new->item - x; new=>next - NULL; return true if the queue is empty, false otherwise int empty (] [ return (qilead == NULL);