• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2032
  • Last Modified:

Hashtable equivalent in MFC C++

Hi All,

I am looking for a fast data structure in c++.  I am currently storing data in a vector<CString> however any time I need to find a value I must traverse the entire vector until I find the specific value I am looking for.  In C# I am able to use a Hashtable to access the specific element I am looking for instantly, without traversing.  Does something like this exist in c++.  I have been playing around with stdext::hash_map<> but am not sure if it is my best option.  Not sure that it isn't either, but I am sort of a novice when it comes to c++ so I wanted to see if there was a better option.

As always, thanks in advance for any help!
  • 2
1 Solution
CMap http://msdn.microsoft.com/en-us/library/s897094z(VS.80).aspx in MFC and hash_map http://msdn.microsoft.com/en-us/library/6x7w9f6z(VS.80).aspx are the most likely equivalents to the Hashtable in C#.
The following data structure from the boost library might also be of interest http://www.boost.org/doc/libs/1_36_0/doc/html/boost/unordered_map.html
I'd definitely prefer 'stdext::hash_map<>' over MFC's CMap if you explicity want a hash table.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now