---1987381667-474183962-925317755=:96368
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hi,
here I tried to use TMap to store pairs of keys and values.
The FindObject(Text_t *) does not work in the example below.
Do I use it wrong ?
Later, I am planning to use TObjNum as the value in
the TMap (that is a number inheriting from TObject, see
http://root.cern.ch/root/html/examples/tcollex.C.html).
Is there a reason why TObjNum is not part of root's classes?
Is there a better why to realize maps between numbers
and strings (keywords) than using TMap ?
thanks for your help
Dirk
Example (also as attachment):
{
#include <iostream>
TObjString *s1 = new TObjString("Alpha");
TObjString *s2 = new TObjString("Beta");
TMap *aMap = new TMap();
aMap->Add((TObject*)s1, (TObject*)s2);
cout << aMap->GetValue(s1)->GetName() << endl;
cout << "o.k., this was correct ... now try retrival using the keyname : " << endl;
cout << aMap->FindObject("Alpha")->GetName() << endl;
cout << "the FindObject method returns null pointer ???? Why ??" << endl;
}
here the output:
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 2.21/01 14 January 1999 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
FreeType Engine v1.1 used to render TrueType fonts.
CINT/ROOT C/C++ Interpreter version 5.13.83, Dec 2 1998
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .x aTMapTester.C
Beta
o.k., this was correct ... now try retrival using the keyname :
Error: illegal pointer to class object FindObject("Alpha") 0x0 3
FILE:/home/dime/cc/prj/RawRead/./aTMapTester.C LINE:19
*** Interpreter error recovered ***
root [1]
---1987381667-474183962-925317755=:96368
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="aTMapTester.C"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.A41.3.95a.990428184235.96368D@rsplus03.cern.ch>
Content-Description:
DQovLyBhVE1hcFRlc3Rlci5DDQoNCnsNCiAgDQojaW5jbHVkZSA8aW9zdHJl
YW0+DQogIA0KICBUT2JqU3RyaW5nICpzMSA9IG5ldyBUT2JqU3RyaW5nKCJB
bHBoYSIpOw0KICBUT2JqU3RyaW5nICpzMiA9IG5ldyBUT2JqU3RyaW5nKCJC
ZXRhIik7DQoNCiAgVE1hcCAqYU1hcCA9IG5ldyBUTWFwKCk7DQoNCiAgYU1h
cC0+QWRkKChUT2JqZWN0KilzMSwgKFRPYmplY3QqKXMyKTsNCiAgDQogIGNv
dXQgPDwgYU1hcC0+R2V0VmFsdWUoczEpLT5HZXROYW1lKCkgPDwgZW5kbDsN
Cg0KICBjb3V0IDw8ICJvLmsuLCB0aGlzIHdhcyBjb3JyZWN0IC4uLiBub3cg
dHJ5IHJldHJpdmFsIHVzaW5nIHRoZSBrZXluYW1lIDogIiA8PCBlbmRsOw0K
DQogIGNvdXQgPDwgYU1hcC0+RmluZE9iamVjdCgiQWxwaGEiKS0+R2V0TmFt
ZSgpIDw8IGVuZGw7DQoNCiAgY291dCA8PCAidGhlIEZpbmRPYmplY3QgbWV0
aG9kIHJldHVybnMgbnVsbCBwb2ludGVyID8/Pz8gV2h5ID8/IiA8PCBlbmRs
Ow0KDQp9DQo=
---1987381667-474183962-925317755=:96368--