CSE250 QueueTestKWR

CSE250 QueueTestKWR - #include...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: #include <iostream> #include <string> #include <vector> #include <fstream> //for Assgt. 3, actually #include <cmath> //for "fabs" on Assgt. 3, if you use it (note: it's wonky) //you may need to do fabs(double(-------)) to disambiguate using namespace std; //class StringDeque;//You MAY need this for Assgt. 3 on your home compiler class StringQueue { public: //class StringDeque; //Causes weird errors on "timberlake"; don't know why friend class StringDeque; private: vector<string>* elements; int frontSpace; int rearItem; int maxAdds; //CLASS INV: frontSpace indicates first empty cell for pushFront // rearItem designates rear item (not space) for popRear--- // ---or if there is no such item, rearItem == frontSpace; public: StringQueue(int maxAdds) : elements(new vector<string>(maxAdds)), frontSpace(0), rearItem(0), maxAdds(maxAdds) { } virtual bool isEmpty() const { return frontSpace == rearItem; } virtual bool isFull() const { return frontSpace == maxAdds; } virtual int size() const { return frontSpace - rearItem; } virtual void pushFront(string newItem) { elements->at(frontSpace++) = newItem; } virtual string popRear() {...
View Full Document

This document was uploaded on 12/11/2011.

Page1 / 3

CSE250 QueueTestKWR - #include...

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