|
From: David M. <ci...@ya...> - 2003-07-01 13:29:07
|
Thanks but I already did that part.
I am relatively new to the STL (I understand most of the
concepts) and am teaching myself by using the refrence
pages on SGI's web site. This works for the containers but
is not so good for the algorithms. I was more looking for
something in the STL that would have made this job a little
easier.
Thanks for the Code Ioannis, however I finished writing
that section of the code up about half-an-hour after I
recieved your first e-mail. this is the layout of the class
that I am building.
typedef int (*func_ptr) (PC_CHAR *, string);
class CMD_TABLE {
public:
CMD_TABLE();
~CMD_TABLE();
void insert(string, func_ptr);
func_ptr lookup(string);
private:
//Was hoping to upgrade this to a hash_map.
//Seems Visual C++ lacks the hash_map header
//Until I can convert the library we are using to
//g++ I hav to use VC. :(
map <string, func_ptr, str_lessthan> cmd_table;
multimap <string, func_ptr, str_lessthan>
reverse_cmd_table;
};
--- Ioannis Vranos <iv...@em...> wrote:
> > -----Original Message-----
> > From: Ioannis Vranos [mailto:iv...@em...]
> > Sent: Monday, June 30, 2003 7:55 PM
> > To: 'Dev-C Mailing List'
> > Subject: RE: [Dev-C++] Reverse Map lookup.
> >
> >
> > > -----Original Message-----
> > > From: dev...@li...
> > > [mailto:dev...@li...] On
> Behalf
> > > Of David McKen
> > > Sent: Monday, June 30, 2003 6:27 PM
> > > To: Dev-C Mailing List
> > > Subject: [Dev-C++] Reverse Map lookup.
>
>
> I had better tell you how you will do it:
>
>
> // Assuming you have stored function addresses in void *.
> map<string, void *>whatever;
>
>
> Let's assume you are looking for a specific address to
> find the string.
>
>
> A map iterator consists of a pair<R,T> which is a struct
> having 2 pointers,
> first and last, first potining to the first elemenet
> (key) and last
> whichh points to the second.
>
>
>
> // Target value
> void *tval=something;
>
>
> for(map<string, void *>const_iterator p=whatever.begin();
> p!=whatever.end();
> ++p)
> {
> // You found the val
> if(p->last==tval)
> //do whatever you want to do with p->first
> }
>
>
>
> I hope this helps David.
>
>
>
>
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL 1: http://run.to/noicys
> * Alternative URL 2: http://www.noicys.cjb.net
>
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET
> sites including
> Data Reports, E-commerce, Portals, and Forums are
> available now.
> Download today and enter to win an XBOX or Visual Studio
> .NET.
>
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
=====
Signed
David Mcken
Life Sucks
Live with it
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
|