Double ended queues are sequence containers with the feature of expansion and contraction on both the ends. They are similar to vectors, but are more efficient in case of insertion and deletion of elements at the end, and also the beginning. Unlike vectors, contiguous storage allocation may not be guaranteed.
The functions for deque are same as vector, with an addition of push and pop operations for both front and back.
> :: iterator it;
(it = g.begin(); it != g.end(); ++it)
"The deque gquiz is : "
"\ngquiz.size() : "
"\ngquiz.max_size() : "
"\ngquiz.at(2) : "
"\ngquiz.front() : "
"\ngquiz.back() : "
"\ngquiz.pop_front() : "
"\ngquiz.pop_back() : "
The output of the above program is :
The deque gquiz is : 15 20 10 30 gquiz.size() : 4 gquiz.max_size() : 4611686018427387903 gquiz.at(2) : 10 gquiz.front() : 15 gquiz.back() : 30 gquiz.pop_front() : 20 10 30 gquiz.pop_back() : 20 10
Disclaimer: This does not belong to TechCodeBit, its an article taken from the below
source and credits.
source and credits: http://www.geeksforgeeks.org
We have built the accelerating growth-oriented website for budding engineers and aspiring job holders of technology companies such as Google, Facebook, and Amazon
If you would like to study our free courses you can join us at
http://www.techcodebit.com. #techcodebit #google #microsoft #facebook #interview portal #jobplacements