Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I filter  keys based on wildcard value in CMapStringToString?

Posted on 2007-11-13
4
Medium Priority
?
487 Views
Last Modified: 2013-11-20
In ASP, I use Dictionary object and "filter" the Keys with a wildcard and I get all the items which has the value  I give. I use the command Filter(array,value...)

Now, I use CMapStringToString inside my VC6++ application for storing Key Value pairs. I need to filter the items which has common text on the key field. How do I do this efficiently?
Thanks
Eugene


------------------------------------------------------------------------
0
Comment
Question by:shiffin
  • 2
  • 2
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 20278165
I don't think there is any functionality to do that for you.

You are likely to have to iterate through each member and check if it will be a match.  There is functionality to return pointers to the strings (more efficient than returning a string value) that would be of help.

Extract from help files

{
    // ...

    typedef CMapStringToString CMyMap;

    CMyMap myMap;
    CString myStr[4]={"One", "Two", "Three", "Four"};
    CMyMap::CPair* pCurVal;

    myMap.InitHashTable( 257 );

    // Add 4 elements to the map.
    myMap.SetAt(myStr[0], "Odd");
    myMap.SetAt(myStr[1], "Even");
    myMap.SetAt(myStr[2], "Odd");
    myMap.SetAt(myStr[3], "Even");

    pCurVal= myMap.PGetFirstAssoc( );                 <<<---------
    while (pCurVal != NULL)
    {
           printf_s("Current key value at %s: %s\n",
                    pCurVal->key, pCurVal->value);
           pCurVal= myMap.PGetNextAssoc(pCurVal);                <<<---------
    }

    // ...
}
0
 

Author Comment

by:shiffin
ID: 20278764
Hi
I still think there must be a way. Because, the "filter" command in ASP Script works efficiently. Save way, there must be some way to achive this.
Below is a sample I am doing on ASP Script

     KeyArr= Filter(MyKeys,"wildcard",true,vbTextCompare)      

I belive there must be a way out in MFC also.
Regards
Eugene
0
 

Author Comment

by:shiffin
ID: 20279549
Hi
I am just trying the maximum efficient way. If there are no other way than this, I can go with this.
Regards
Eugene
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 1500 total points
ID: 20279634
The 'filter' in ASP may well work but that isn't necessarily using a CMapStringToString.
You are comparing chalk with cheese
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

886 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