Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CMap example

1,473 views
Skip to first unread message

Dr. Harald Busch

unread,
Aug 13, 1998, 3:00:00 AM8/13/98
to
Hi,
has anybody got a simple example for something like
CMap<CString,CString, MyClass*, MyClass*&> ?
Thanks
Harald

harald-...@hl.siemens.de

vcard.vcf

Matthew Stanfield

unread,
Aug 13, 1998, 3:00:00 AM8/13/98
to Dr. Harald Busch
Dr. Harald Busch wrote:
> has anybody got a simple example for something like
> CMap<CString,CString, MyClass*, MyClass*&> ?

I tried to get an example a few weeks ago when I needed a binary search
tree - I was shocked to find that MFC/VC++ has no built in BST or BT and
that you have to use CMap. The documentation of CMap is so bad that I
eventually gave up and used CObList's instead since speed was not a big
issue. If you succeed in finding a simple example please forward it to me
and maybe I'll re-implement my CObLists as a CMap.

Regards,

..matthew

Gregory Malocha

unread,
Aug 13, 1998, 3:00:00 AM8/13/98
to
// template< class KEY, class ARG_KEY, class VALUE, class ARG_VALUE >class
CMap : public CObject
typedef CMap<CString, const char*, MyClass*, MyClass*&> CMyMap;

// declare it
CMyMap myMap;

// use it
// find data element
//BOOL Lookup( ARG_KEY key, VALUE& rValue ) const;
MyClass* pMyClass = NULL;
myMap.Lookup("Hello", pMyClass);

// set data element (add or replace)
//void SetAt( ARG_KEY key, ARG_VALUE newValue );
myMap.SetAt("Hello", pMyClass);

// iterate map
CString aKeyName;
for(POSITION Pos = myMap.GetStartPosition(); Pos != NULL; )
{
myMap.GetNextAssoc( Pos, aKeyName, pMyClass );
// ...
}

Hope this helps.

Regards,
Gregory Malocha.
Sezam Technologies.


Dr. Harald Busch wrote in message <35D2B39E...@hl.siemens.de>...
>Hi,


>has anybody got a simple example for something like
>CMap<CString,CString, MyClass*, MyClass*&> ?

>Thanks
>Harald
>
>harald-...@hl.siemens.de
>

0 new messages