ok here is my queue function that prints all the values
Code:
void Queue::displayAll()
{
if (isEmpty()) cout << "Empty ";
QueueNode *temp = frontPtr;
while (temp!= NULL)
{
cout << temp->item.word<<" line: ";
cout << temp->item.line<<endl;
temp = temp->next;
}
} // end
I declared my linked list like this with a back pointer and a frontpointer.
Code:
struct JOB {
string word;
int line;
};
typedef JOB QueueItemType;
struct QueueNode {
QueueItemType item;
QueueNode *next;
}; // end struct
QueueNode *backPtr;
QueueNode *frontPtr;
}; // end class
so what im doing is printing the word the user enters up to 200 then I will list them like this.
Concordance:
A: 3 5 10
ABLE: 4
AND: 6
ANYWAY: 11
APPEARS: 2
AS: 5
ASK: 9 10
COLLAPSED: 7
CONCORDANCE: 3
DOG: 9 11
HE: 5 6 7
HE'D: 10
HOW: 4
the numbers being the line in which the word appears, but right now my displayall function will show the word even if it appears on a different line separately like this take A for example:
A: 3 5 10
mine will be
A: 3
A: 5
A: 10
I tried a few if statements to check if the next word is the same as current word like this:
if(temp.item.word==temp.next)
and
if (temp->>item==temp->>next->>item.next)