+ 4
Why we need vector, queue, stack if we already have double ended queue in cpp ?
9 Réponses
+ 4
Well stack is also in STL.
The difference between them is that in stack you have just push and pop(stack data structure) but dequeue is more like a vector, where u can go to any element of it or even insert().. basically you can use dequeue for anything u use stack for. It's just that some people find it easier and less confusing to use stack when you only need pop() and push()...
+ 2
LIFO access is natural via a stack
+ 1
STL dude
we have dequeue<int>de; in dequeue we have both pop_front() and pop_back() , front() and back()
+ 1
Mate STL is a library ;)
+ 1
Martin Taylor, yeah I totally know that... How is it different from what I said?
+ 1
Martin Taylor , right I've confused some things.... Thanks for explanation bro.
0
Mate, stack is a double ended queue...
Not sure what u mean by "we already have double ended queue in CPP" but there is a std::<stack> header in C++.
0
And I'm asking about STL.
0
Martin Taylor, queue might be both LIFO and FIFO.
Stack is just one example of double ended queue.
As you said double ended queue is not a stack but stack is a specific type of double ended queue....