100 ++ - all

1, to achieve the deque:
Dynamic two-dimensional array:
two-dimensional pointer give a first allocation space, that is, a distribution of n pointers space, then a pointer to give the inside of each
allocated space, thus forming a dynamic two-dimensional array

deque allocates space only to the first dimension, and then find the middle position pos (forward and backward to ensure that there is enough space), and then to the position of the allocated space

When this runs out of space back, plus a pos, pos and then to the new space applications, using the new pos continue to store. Similar forward.
* Forward storage stores from back to front

2, deque iterator:
iterator variable has four members
in my family which - the position of the current iterator
my house where to start - the current iteration is located one-dimensional array starting position
my house from which end - Current iterator where the one-dimensional array of end position
my home where - the current address iterator where the one-dimensional array

3, deque expansion:
When the forward or backward space map filled, if it needs to store new data, it is necessary expansion.
Expansion only for the map, does not have any impact on the existing one-dimensional array. (Copy map the address space to a new expansion, the shallow copy)
after expansion map, a pointer to the original data center will space into new applications, to complete expansion.

Published 77 original articles · won praise 23 · views 7540

Guess you like

Origin blog.csdn.net/Hots3y/article/details/102508915