PDA

View Full Version : Template stack, isn't there is a FIFO ?



yellowmat
3rd March 2006, 10:33
Hi, I found a LIFO (QValueStack) but I don't find a FIFO, it does not exists ?

If it does not exists, what kind of template should I use in order to have the behaviour of a FIFO ?

Thanks in advance.

yellowmat
3rd March 2006, 10:38
Hmm, I could use the QValueList and its first/last, pop_front/pop_back, push_front/push_back functions for such a behaviour, but it is not a stack.

wysota
3rd March 2006, 12:33
There is a QValueStack class (and its cousin QPtrStack).

zlatko
3rd March 2006, 12:35
You always can give stack singularity to your own inherits from QValueList class ;)

jacek
3rd March 2006, 14:15
Hmm, I could use the QValueList and its first/last, pop_front/pop_back, push_front/push_back functions for such a behaviour, but it is not a stack.
There is no such thing as FIFO stack --- stacks always have LIFO access. What you need is a queue.

QValueList implements both stack and queue interfaces. If you don't like it, you can write your own class that encapsulates QValueList and delivers only queue interface.

wysota
3rd March 2006, 14:49
There is a QPtrQueue class if you can use pointers and not values. And of course std::queue.