Deque

The name deque means double-ended queue, which means that it can grow from both ends, and, although you can insert items in the middle, it is more expensive. As a queue, it means that the items are ordered, but, because the items can be put into the queue from either end, the order is not necessarily the same order in which you put items into the container.

The interface of deque is similar to a vector, so you have iterator access as well as random access using the at function and the [] operator. As with a vector, you can access items from the end of a deque container using the push_back, pop_back, and back methods, but, unlike a vector, you can also access the front of a deque container using the push_front, pop_front, and front methods. Although the deque class has methods to allow you to insert and erase items within the container, and to resize, these are expensive operations, and if you need to use them then you should reconsider using this container type. Furthermore, the deque class does not have methods to pre-allocate memory, so, potentially, when you add an item to this container, it could cause a memory allocation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset