STL's Deque

Source: Internet
Author: User

Deque is an optimized, basic sequence container for adding and removing operations to two segments of a sequence. It allows for faster random access, but it does not keep all objects in a contiguous block of memory like a vector, but instead uses multiple contiguous blocks of storage. Adding or removing elements to the Deque two segment is a small cost. It does not need to reallocate space, so adding elements to the end is more efficient than vector.

In fact, Deque is a combination of the pros and cons of vectors and lists, which is a container between the two.

Features of Deque:

1, random access convenience, that is, support [] and vector.at (), but the performance of the vector is not good.

2. Insert and delete operations can be done internally, but performance is less than list.

3. Push and pop can be performed at both ends.

4. Use more memory relative to vector.

Some basic uses of deque:

STL's Deque

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.