Vector Class Discussion

valarray class
Author: Agner Date: 2014-04-10 06:50
You are right. It makes little difference what container you are using, as long as the memory is contiguous. There may be a little overhead to iterators and bounds checking, but that's all. You may as well just make a simple array that is sure to be big enough, or use "new" if you need variable size.

The other containers in STL (lists, maps, etc.) are chopping up the memory in a lot of small allocated units, sometimes it has more allocated memory blocks than the number of elements in the container. These containers should be avoided where speed is critical.

 
thread valarray class new - Kyle Bentley - 2014-04-07
last replythread valarray class new - Agner - 2014-04-08
last replythread valarray class new - Kyle Bentley - 2014-04-09
last reply valarray class - Agner - 2014-04-10