Re: an attempt to get it right

Rene Brun (Rene.Brun@cern.ch)
Mon, 24 Feb 1997 18:36:04 +0100


Jacek M. Holeczek wrote:
>
> After painfull FindObject lesson ( life is brutal and full of ambrushes )
> I decided to try as simple as possible container class.
> My guess was TObjArray. I intended to :
> if (RawCamac=(TObjArray*)gDirectory->GetList()->FindObject("RawCamac"))
> and then :
> if (RawCamac[i]) { ... }
> This array would keep pointers to histograms which would reside in a
> separate subdirectory, so that the gDirectory itself could keep only the
> "top" level objects ( one of them would be this array ), thus finding
> objects would be fast. Unfortunately I have noticed that TObjArray does
> NOT inherit from TNamed, so I cannot FindObject it ( seems that none of
> container classes inherits from TNamed ). Then I am looking for a simplest
> built-in root class which would be able to have NAME and keep a table of
> pointers to histograms ( so no "TH1F *histos[1000]" allowed, the
> TObjArray would be perfect for me except that it has no name ;-( ).
> Any help appreciated ( maybe TBranch ? ).

Why do you want to insert this object in gDirectory? Why a global
pointing to your TObjArray is not OK?
Obviously, we could have one class derived from TNamed.
I believe, however, that this should be a small user class
derived from TObjArray with a name component and a GetName() member
function + all the functionality to search what you want.

> While looking at some root classes I have found some possible extentions
> which should not be difficult/time-consuming to implement.
> 1. implement TH*I and TH*L histogram classes

This has always been on our shoping list and it is easy to add.

> 2. some collection classes ( including TObjArray ) have the At(),
> RemoveAt(), but NONE has DeleteAt(), so I propose to implement
> DeleteAt() which should "remove" object At() and delete it if
> is it on the heap

We will implement DeleteAt.

> 3. currently the AddAtAndExpand() doubles the size of the array,
> but I think it should only increase the size by the INITIAL
> aray size ( default is kInitCapacity=16 )

This is for efficiency reasons. It is frequent to use the default
initial capacity in the array constructor. In case of large lists,
we want to minimize the number of reallocs.

Rene Brun