Hi Guys,

In my current task , I need to read the read the approximately 10,000 recoreds from database and need to store the same in container.Now i need to select container to store all this records inorder to generate the report.Could you let me know whether i need to use vector or list and why? I have selected vector from my end as i don't require any kind of insertion in the middle and no searching effort is required.Apart from this after insertion i need to sort the all the records based on Name field.

Recommended Answers

All 2 Replies

Use a map, based upon the Name field. If the Name field is not unique, then use a multimap.

Thanks for your replay.i got to know that sorted vector will be more usefull then map if continous insertion and deletion and searching effort is not required.Apart from this i also would like to know what container would you suggest if sorting effor is not required at all.

below is the some usefull pointers which i found yesterday in scott meyers book (Effective STL)

Item 23. Consider replacing associative containers with sorted vectors

"**The standard associative containers are typically implemented as balanced binary search trees. A balanced binary search tree is a data structure that is optimized for a mixed combination of insertions, erasures, and lookups. That is, it's designed for applications that do some insertions, then some lookups, then maybe some more inser-tions, then perhaps some erasures, then a few more lookups, then more insertions or erasures, then more lookups, etc. The key characteristic of this sequence of events is that the insertions, erasures, and lookups are all mixed up. In general, there's no way to predict what the next operation on the tree will be"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.