delete/remove object from TList by name

From: Rutger van der Eijk (r36@nikhef.nl)
Date: Fri Sep 04 1998 - 16:17:03 MEST


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



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