deque best practices

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


This is what mentioned in the book The C++ Standard Library, section 6.3 Deques,

--------------------
In summary, you should prefer a deque if the following is true:

You don't refer to elements of the container.

It is important that the container frees memory when it is no longer used (however, the standard does not guarantee that this happens).
--------------------

My confusions,

1. What means "refer to elements of the container"? We should not do that? Why -- we always refer to elements in the container? When we use iterator of deque to acccess elements in deque container, we always refer to elements of container, right? What does the author mean?

2. I think whether deque container implementation actually free the memory when we do erase or pop or just mark it as freed to reserve for future use (e.g. insert or push) is up to implementation details, does this point to be a reason why we use deque? Confused.


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

size and iterator of deque 0
deque 0
deque and thread-safety 0
iterator for deque 0
Questions about std::vector and std::deque 2
deque questions 4
implementation of vector, deque 7
redundant allocation 0

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top