Print

Print


Robert,

On 03/28/2014 07:46 PM, Robert Lupton the Good wrote:
>>   1) std::list --> std::vector
>>      - why? Default now is vector, iterating over vector
>>        is much more efficient than over list
>>      - reason why we use lists: want to convey the intent
>>        (put things in the end, remove from the end etc),
>>        yes can be implemented through vector
>>      - revisit on case by case bases, do not blindly replace
>>      - preferred solution: typedef, and name it in a way that
>>        conveys the intent (e.g., might call it a "container"),
>>        underneath use vector
> If you just want to insert at each end, isn't a dequeue better?  And see Meyers "Effective STL" on why it may not be a good idea to typedef a container --- he certainly thinks that you should choose the STL type and expose it.
The point was to use a typedef (e.g., FooContainer) to convey the intent 
of code that just needs a dumb container of Foo whose implementation is 
not important.

Meyers seems to think it's useless to write container-independent code, 
but also suggests typedefs for encapsulating the selection of the STL 
type. Okay, he does say one should carefully consider all the options, 
and disagrees with the C++ standard's recommendation of vector as the 
default.

I'm starting to be convinced by AndyS's argument that we should just 
choose vector, but I still feel like I want to convey the intent of "I 
just need a container for Foo; not sure what the best container is; 
haven't done the study."

-Daniel

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the QSERV-L list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=QSERV-L&A=1