This document provides an in-depth analysis of STD: deque and provides a guiding ideology: when considering memory allocation and execution performance, Using STD: deque is better than STD: vector.
Introduction
This article thoroughly studies
In the past, we thought that the vector and deque were almost the same. In terms of efficiency, deque and vector were close, so we should simply use the efficient vector.However, if I ignore the other party, there is a reason for a transaction to
C ++ Primer study note _ 12 _ Standard Template Library _ deque dual-end queue container, _ 12 deque
C ++ Primer study note _ 12 _ Standard Template Library _ deque dual-end queue container
The deque dual-end queue container uses a linear table
The constructors of deque and vectors in STL, assign are basically the same, focusing on the characteristics of deque, the main differences between deque and vectors are as follows:
Deque is the data structure of a two-terminal queue, which can
C + + STL container deque is similar to vector, and also uses a dynamic array to manage elements.
You need to include the header file before using deque:
#include
It is a class template defined within a namespace std:
TemplateClass _ax = allocator
"Vector is the continuous linear space of one-way open, while deque is the continuous space of two-way open. The so-called bidirectional opening means that you can insert and delete elements at the beginning and end. Of course, vector can also be
Deque bidirectional queue is a two-way open continuous linear space that can efficiently insert and delete elements at both ends of the head and end to provide random access. deque is very similar to vector on the interface, the following lists
The deque structure can be viewed as an enhanced version of the built-in list structure and provides more powerful methods than queues. The following describes the deque dual-end queue structure in the collections module of Python through several
The C ++ STL container deque is similar to the vector and uses dynamic arrays to manage elements.
Before using deque, you must include the header file:
# Include
It is a class template defined in the namespace STD:
Template Class _ AX = Allocator
1) Overview
Deque is a sequence container and a bidirectional open continuous linear space. You can insert and delete elements at the beginning and end respectively. Of course, you can also perform a vector action at both ends of the header and end,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.