Re: delete/remove object from TList by name

From: Fons Rademakers (rdm@pcsalo.cern.ch)
Date: Fri Sep 04 1998 - 20:20:36 MEST


Hi Rutger,

   this looks reasonable. I'll see how to implement is for all collections.

Cheers, Fons.


> Hi,
> 
> I want to remove an object from a TList. From this object I only have a
> it's name. It seems to me that I have to loop through the TList twice to
> remove the object. What I do:
> 
> I have:
> 
> TList *fList; // containing several objects
> Text_t *name; // which has the name of an object in fList to be removed
> 
> I do:
> 
> TObject *obj = fList->FindObject(name);
> fList->Remove(obj);
> 
> Looking into the code I see that both members of TList loop through the
> list. What I would like is:
> 
> fList->Remove(name);
> 
> Not iterating the list twice in this case could also be achieved if we
> get a member 
> 
> TObjLink TList::FindObject(name);
> 
> and then use
> 
> TList::DeleteLink(TObjLink *lnk);
> 
> but this is (correctly!, becuase a user of TList should not have to know
> it is implemented with TObjLinks) a protected memeber. 
> 
> If I don't miss another option to achieve this my 'request for
> enhancement' is to implement TList::Remove(name). It shouldn't be to
> difficult, and can safe time in case of long lists.
> 
> Thanks,
> 
> Rutger van der Eijk
> 


-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET