Reputation: 9
In my program iam used CArray for storing some values. But the performance is low when using CArray member functions. such as iterating the CArray. iam used member function like Copy, GetAt, Append, etc. because of low performance iam decided to use CMap class instead of CArray. Is my decision is correct? anyone explain it?
Upvotes: 0
Views: 1040
Reputation: 1531
Have a look at this: Recommendations for Choosing a Collection Class
We must select the collection class not only based on performance. It depends on the kind of data structure you want, operations you want to perform on it etc.
Since you said you want to "store some values" I assume no further complexity. For that, you can use either a CArray
or CList
. Lists are faster when inserting a value, but it is not indexed. i.e you cannot access the elements at a particular index, you need to traverse the list instead.
CMap
is faster than both CArray
and CList
, but it is better to use it if you have a collection of complex data structure where a unique key is available to index each element.
Upvotes: 2