In your peek check if size() == 0 instead. And for dequeAll just deque until size == 0
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
Why do you have a Queue_head pointer (initialized to and compared against zero instead of NULL) when the comments in your header say there are just the two pointers frontPtr and backPtr? Just use those. Also, if you're going to track Size separately, then you should initialize it in your constructors and update it in enqueue and dequeue.
raptr_dflo
Practically a Master Poster
602 posts since Aug 2010
Reputation Points: 76
Solved Threads: 82
When you enqueue, increase size by one, and when you dequeue decrease size by one. But make sure your adding and removing valid data. So only increase size if you add valid data and decrease size if removing valid size.
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
For you size()const function just return size, no need to check if its equal to 0 or not.
For your peek you should return a constant reference like so :
template<typename Type>
const Type& peek()const{
return head;
}
and for your dequeue you have a choice, either not return nothing or return the popped element. If you wan to return the popped element then make a copy for the popped element remove the element, and return the copy.
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608