Introduction to STL and common containers vector, list and deque

       Vector is similar to a built-in array, it has a continuous memory space, and the starting address remains unchanged, so it can support random access very well , that is, the [] operator , that is, it can be accessed by array subscript or traverse. But because its memory space is continuous, inserting and deleting in the middle will cause a copy of the memory block . In addition, when the memory space behind the array is not enough, it is necessary to re-apply for a large enough memory and copy the memory. These have greatly affected the efficiency of vector.  
   
    list is a doubly linked list in the data structure ( according to sgi stl source code), so its memory space can be discontinuous

Guess you like

Origin blog.csdn.net/chenlycly/article/details/40833685