Hi everyone:
I'm tring to use the core::list as a simple queue but i'm not sure if
tjis can be. It's an idea not really tested. Any sugestion is wellcome.
Thanks in advance.
Your implementation is really weird for several reasons.
It isn't a queue, it is a stack. Almost. You push onto the back, and you pop from the back. With a queue, you'd push on the front and pop from the back, or vice versa.
The front() method doesn't return the front element, it actually walks the list from front to back, and then back around to the front.
For an actual queue implementation, you don't need the iterator members.
There is no need to clear the list in the destructor. That will happen automatically.
The queue keeps pointers to objects, but it looks like you really only need to keep objects by value.
The push() function doesn't insert objects if the queue is already full. If the user allocated the object from the heap, they would hae no way to know if the operation failed or not, and if it did, they'd never be able to deallocate the object that they wanted inserted.
If your queue does actually need to have a maximum number of events, the MAX_EVENTS member should probably be a template parameter or a parameter to the constructor. Either that, or it shouldn't have a maximum length, and the application should keep track of the max.
To be more useful, and generic, you might want to consider templatizing it.
Hi:
Thanks for the corrections. made a little modifications and woks ok, And you are right is not a queue but i need some attributes from a queue and a stack.
Actually i need to traverse the list with the Front() in a circular fashion, always getting the next element. The total of pushed items must be limited,
hi priority pushed at front, low priority at list back, poping from back.
Thanks.