Re: [ROOT] TObjArray size methods

From: Vladimir Nagaslaev (vnagasl@fnal.gov)
Date: Tue Mar 06 2001 - 19:34:09 MET


   Thanks Fon,

 I was looking in the TObject class also, but didn't see
GetSize method there. Anyway, according to the classindex browser,
it is defined in TCollection header file:

GetSize() const { return fSize; }

and in the same header file (TCollection.h) I found:

Int_t     fSize;               //number of elements in collection

that's why I got confused.

  Vladimir.



On Tue, 6 Mar 2001, Fons Rademakers wrote:

> Hi Vladimir,
>
>    TObjArray::GetSize() returns the size of the TObjArray, i.e.
> the number of available slots. When doing:
>
> TObjArray a;       // uses TCollection: :kInitCapacity=16 as default
size
> a.GetSize();       // returns 16
> TObjArray a2(1000);
> a2.GetSize();      // returns 1000
>
> GetLast() returns the last occupied slot.
>
> Cheers, Fons.
>
>
>
> Vladimir Nagaslaev wrote:
> >
> >   Who knows what does the method TObjArray::GetSize() do?
> > It always returns 16 on my platform, whatever the actual
> > size of the array is. Just guessing that its meaning is
> > the same as "size" in STL containers leads to bad things.
> > TObjArray::GetLast() works better, but without good description
> > I'm not sure it's a good thing to do.
> >
> >   Vladimir.
>
> --
> Org:    CERN, European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23, Switzerland
> E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:39 MET