Re: CArray vs CMap
"John" <email@example.com> ha scritto nel messaggio
Thank you for your prompt response.
So, CMap has performance issue. Then what is the benefit with CMap?
To search, CArray object. Is it correct?
CMap and CArray are both valid tools, but for different tasks.
If the key is an integer represented by item position, then there is no
doubt in choosing CArray< Class >.
But if you want to access the items stored in a container using a different
kind of key, for example a string, then CMap is the tool to choose.
(Note that there are also STL containers, like std::vector, std::map, etc.
which seems to be more carefully designed than MFC containers, at the cost
of maybe a bit more hard learning curve. However, STL containers with their
"ecosystem" of iterators and algorithms are a very versatile and powerful
tool, if you can invest some time and intellectual energy to learn them.)
I would suggest a series of articles illustrating some data structures, that
is written for C# but can be very useful for the C++ programmer, too:
Algorithms and Data Structures
An Extensive Examination of Data Structures (2.0)
In particular, you may read the first two parts (when arrays and hashtables