Re: Q: ROOT collection classes vs STL containers

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Thu May 15 1997 - 16:33:11 MEST


Hi Pasha,

   we have looked at template based containers before the STL
existed and at that time it was basically impossible to use
because of the very rudimentary template support (begin 95).

As I mentioned before, STL is a mixed blessing in a framework
environment. It is very good for typesafe containers but the
problem is that you have to do quite some work to integrate them
properly into a framework. Since the polymorphic ROOT containers
are an essential part of the framework it is very simple
to build complex class hierarchies and still support a simple
comprehensive I/O model (e.g. container.Write() will write-out
all objects in the container to the database). It would be 
possible to support STL based containers containing objects
inheriting from TObject. In that case we would have to
generate the correct iterator loop to write the container
elements in the Streamer() functions (as opposed to the simple
container.Write()). If typesafety of container elements is your
worry than use the function TCollection::AssertClass() to make
sure that all elements in the container inherit from an expected
base class (this is possible thanks to the very extensive RTTI 
information available to all TObject derived objects).

Concerning performance. The only performance penalty incured 
by polymorphic containers is one memory indirection (due to 
the virtual function call). However, we have not extensively 
measured the ROOT container performance vs. STL containers.
Probably we should do that some time.

Tto summarize. You could use STL containers in your classes
and populate them with TObject derived objects. To get I/O
and Inspect() and Dump() facilities for these classes you
will have to write custom Streamer() and ShowMembers()
methods (the ones generated by rootcint).

Cheers, Fons.

Pasha Murat wrote:
> 
>         Hi,
> 
> I wonder if anybody compared ROOT collections vs STL containers from the
> point of view of performance.
> It is clear that using STL leads at present to huge executables, which is
> not a nice feature.
> On the other hand implementation of ROOT collections is based on
> abstract classes, so simultaneous use of many collection classes may lead
> to a noticeable performance degradation.
> 
>                                                 Thanks, Pasha.

-- 
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:26:18 MET