Hashtable equivalent in MFC C++

Posted on 2009-02-18
Last Modified: 2013-12-14
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!
Question by:mdw233
    LVL 19

    Accepted Solution

    CMap in MFC and hash_map are the most likely equivalents to the Hashtable in C#.
    LVL 19

    Expert Comment

    The following data structure from the boost library might also be of interest
    LVL 86

    Expert Comment

    I'd definitely prefer 'stdext::hash_map<>' over MFC's CMap if you explicity want a hash table.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now