STL (3) container deque

common sense

insert image description hereinsert image description here
insert image description here
(The picture above shows a bit similar to an index)
Although it looks like a double-ended array, it is not as fast as a single-ended array vector. The reason is that the continuity of its elements is maintained by the central controller. When accessing an element randomly You need to find the address from the central controller first, and then go to the buffer to find it. Of course, it also supports random access.

deque constructor

insert image description here

deque<int>d1;
deque<int>d2(d1.begin(),d2.end());
deque<int>d3(10,100);//d3是10个100

deque assignment operation

insert image description here

Deque size operation

insert image description here

Deque insertion and deletion

insert image description here

Deque access operation

insert image description here

deque container sorting

insert image description here

Guess you like

Origin blog.csdn.net/weixin_45866980/article/details/126395391