Trying to find an answer I realized that some of the container
classes (like TObjArray) could be used outside ROOT, others (like TOrdCollection)
require TROOT object to be initialized.
The thing which confuses me a little bit is the following.
TOrdCollection class uses RTTI when TOrdCollection::IndexOf(TObject *obj)
tries to define location of the object in the list. Here is its source
code (taken from 1.03/09):
--------------------------------------------------------------------------------
Int_t TOrdCollection::IndexOf(TObject *obj) const
{
// Return index of object in collection. Returns -1 when object not found.
// Uses member IsEqual() to find object.
for (Int_t i = 0; i < GetSize(); i++)
if (fCont[PhysIndex(i)]->IsEqual(obj))
return i;
return -1;
}
--------------------------------------------------------------------------------
TOrdCollection::IsEqual calls ROOT RTTI.
Given the collection contains pointers to TObjects, why is it necessary to
use RTTI when comparing TObject* to TObject* ? Isn't it enough just to compare
to pointers to each other? Or this is related to ROOT I/O and persistency
mechanism?
Thanks, Pasha.