Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

14 Experts available now in Live!

Get 1:1 Help Now