Sorry Boris,
what I sent only works for files. Use TDirectory::GetList() for
in-memory objects:
>> TIter nextobj(gROOT->GetList());
>> TObject *obj=0;
>> while ((obj = nextobj()))
>> if (obj->Class()
>> && obj->Class()->InheritsFrom( TH1::Class() )
>> delete obj;
Axel.
Axel Naumann wrote:
> Hi Boris, > use "delete obj". gDirectory could also be the current file, so > explicitly using gROOT is safer. And this code snippet should be a bit > faster: > >
> > > Note how it compares pointers instead of strings, only tests for TH1 > (TH2 derives from TH1, so whatever is satisfied by > InheritsFrom(TH2::Class()) will also be satisfied by > InheritsFrom(TH1::Class())), and reads the key only if the class matches > (which is not really relevant for in memory objects). > > Axel. > > Boris Skorodumov wrote: >
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET