Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-13
4
Medium Priority
?
485 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

670 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