Hi Dirk, this is fixed now in the development version. The GetName() method for the TMap helper class TAssoc was not implemented. Thanks for reporting this inconsistency. Cheers, Fons. Dirk Meier wrote: > > 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] > > -------------------------------------------------------------------------------- > > // aTMapTester.C > > { > > #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; > > } -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:32 MET