Solved

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

Posted on 2007-11-13
4
476 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 44

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 44

Accepted Solution

by:
AndyAinscow earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
if loop in java 3 129
Creating an alias to a directory so I can change the directory 'contents' by changing the alias 5 85
bigDiff challenge 17 84
java ^ examples 8 62
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

17 Experts available now in Live!

Get 1:1 Help Now