Re: [ROOT] TIter, TIterator, and user-defined iterators

From: George Heintzelman (gah@bnl.gov)
Date: Thu Jul 27 2000 - 23:23:14 MEST


> Hi George,
> 
> TIter is a generic iterator for TCollection based containers.
> just in constructor it demands this collecion
>   TIter(TCollection* col ..)

TIter also has two other constructors.

TIter(TIterator *) is one of them. So I can provide anything which is a 
TIterator to TIter and it will use it.

Unfortunately, the current definition of TIterator requires it to 
supply a meaningful GetCollection, and that that Collection's 
MakeIterator class return a TIterator of the original type, 
requirements which are IMHO somewhat onerous and unnecessary. If this 
is violated, I will be unable to copy the resultant TIter's.

There are two other ways of making a TIter.
> It is impossible in C++ to make general polimorphic wrapper class for arbitrary 
> collection. It is not a problem of ROOT.

I can't make a class that without any work provides an iterator for an 
arbitrary class, true. What I CAN do is make an abstract base class 
which allows me to implement such a wrapper for an arbitrary container. 
TIterator comes close to that (for containers of TObject-descended 
objects) but is not quite there. That's what I'm proposing making 
possible.

IOW: I would write the wrapper around std::list<T>::iterator which 
derives from TIterator and turns the root notation into the STL 
iterator notation.

It's not a problem for ROOT per se. It is a problem for people like me 
who like parts of ROOT but want to be able to use other tools inside 
ROOT.

George Heintzelman
gah@bnl.gov



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET