CS215queue(2o5)

CS215queue(2o5) - #include using namespace std#include"CS215queue.h CS215queue:CS215queue CONSTRUCTOR qFront = NULL Initialize to empty

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std #include "CS215queue.h" CS215queue::CS215queue( ) // CONSTRUCTOR { qFront = NULL // Initialize to empty queue qRear = NULL } bool CS215queue::IsEmpty( ) const // Returns true if queue empty // Pre: queue exsists // Post: return true if elements in queue { return ( qFront == NULL ) } bool CS215queue::IsFull( ) const // Returns true if queue full // Pre: queue exsists // Post: Always return false // Linked list queue cannot be full { return ( false ) } void CS215queue::Enqueue( int newItem ) // Adds newItem to the rear of the queue. // Pre: Queue has been initialized. // Queue is not full. // newItem is elemnet to add to queue // Post: newItem is at rear of queue. { NodeType* ptr ptr = new NodeType // Get new node ptr->info = newItem // Put in data ptr->next = NULL // End of list if ( qRear == NULL ) // Empty queue? qFront = ptr // point to this node else qRear->next = ptr // queue at end qRear = ptr // this node is at rear }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/13/2008 for the course CS 215 taught by Professor Piwowarski during the Spring '06 term at Kentucky.

Page1 / 2

CS215queue(2o5) - #include using namespace std#include"CS215queue.h CS215queue:CS215queue CONSTRUCTOR qFront = NULL Initialize to empty

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online