Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 52
Detect CR LF to each line 12 174
abstract class with all non abstract mentods 6 84
Detect file exist or not 3 198
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 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