Difference between vector and deques

Source: Internet
Author: User

Similarities: 1. It is slow to insert or remove elements in the middle section because all elements need to be moved to free up or fill up space. 2. The iterator belongs to Radom access iterator (then access iteration). Differences 1. deques can quickly insert and remove elements at both ends, while vector can only operate at the end. These operations can be completed in anortized constant time. 2. when an element is accessed, there is an indirect process in the deque internal structure, so the element access and iterator operations will be a little slower. 3. The deque iterator must jump between different regions. Therefore, it must be a pointer of a special rank, not a general pointer. 4. For systems with limited memory blocks (such as PC systems), deque can contain more elements because it uses more than one memory, so deque's max_size () may be larger. 5. The deque memory zone will be released when it is not used. The memory size of deque can be reduced. But whether this is the case depends on the actual compiling environment.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.