ROOT » CORE » CONT » TCollection

class TCollection: public TObject


Collection abstract base class. This class describes the base
protocol all collection classes have to implement. The ROOT
collection classes always store pointers to objects that inherit
from TObject. They never adopt the objects. Therefore, it is the
user's responsability to take care of deleting the actual objects
once they are not needed anymore. In exceptional cases, when the
user is 100% sure nothing else is referencing the objects in the
collection, one can delete all objects and the collection at the
same time using the Delete() function.

Collections can be iterated using an iterator object (see
TIterator). Depending on the concrete collection class there may be
some additional methods of iterating. See the repective classes.

TCollection inherits from TObject since we want to be able to have
collections of collections.

In a later release the collections may become templatized.


/* */

Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~TCollection()
voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(TObject* obj)
virtual voidAddAll(const TCollection* col)
voidAddVector(TObject* obj1)
virtual voidTObject::AppendPad(Option_t* option = "")
Bool_tAssertClass(TClass* cl) const
TIterbegin() const
virtual voidBrowse(TBrowser* b)
Int_tCapacity() const
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidClear(Option_t* option = "")
virtual TObject*Clone(const char* newname = "") const
virtual Int_tCompare(const TObject* obj) const
Bool_tContains(const char* name) const
Bool_tContains(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidDelete(Option_t* option = "")
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidDraw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidDump() const
static voidEmptyGarbageCollection()
TIterend() const
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*FindObject(const char* name) const
virtual TObject*FindObject(const TObject* obj) const
static voidGarbageCollect(TObject* obj)
static TCollection*GetCurrentCollection()
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tGetEntries() const
virtual const char*TObject::GetIconName() const
virtual const char*GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
virtual TObject**GetObjectRef(const TObject* obj) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual Int_tGetSize() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Int_tGrowBy(Int_t delta) const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tHash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tIsArgNull(const char* where, const TObject* obj) const
virtual Bool_tIsEmpty() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tIsFolder() const
Bool_tTObject::IsOnHeap() const
Bool_tIsOwner() const
virtual Bool_tIsSortable() const
Bool_tTObject::IsZombie() const
virtual voidls(Option_t* option = "") const
virtual TIterator*MakeIterator(Bool_t dir = kIterForward) const
virtual TIterator*MakeReverseIterator() const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject*operator()(const char* name) const
virtual voidPaint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* option = "") const
virtual voidPrint(Option_t* option, Int_t recurse) const
virtual voidPrint(Option_t* option, const char* wildcard, Int_t recurse = 1) const
virtual voidPrint(Option_t* option, TPRegexp& regexp, Int_t recurse = 1) const
virtual Int_tTObject::Read(const char* name)
virtual voidRecursiveRemove(TObject* obj)
virtual TObject*Remove(TObject* obj)
voidRemoveAll()
virtual voidRemoveAll(TCollection* col)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCurrentCollection()
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetName(const char* name)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidSetOwner(Bool_t enable = kTRUE)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp) const
static voidStartGarbageCollection()
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tWrite(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tWrite(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual const char*GetCollectionEntryName(TObject* entry) const
voidTObject::MakeZombie()
virtual voidPrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
virtual voidPrintCollectionHeader(Option_t* option) const
TCollection()
private:
voidoperator=(const TCollection&)
TCollection(const TCollection&)

Data Members

public:
static TObject::<anonymous>TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TCollection::<anonymous>kInitCapacity
static TCollection::<anonymous>kInitHashTableCapacity
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::<anonymous>TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::<anonymous>TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::<anonymous>TObject::kOverwrite
static TObject::<anonymous>TObject::kSingleKey
static TObject::<anonymous>TObject::kWriteDelete
static TObject::<anonymous>TObject::kZombie
protected:
TStringfNamename of the collection
Int_tfSizenumber of elements in collection
static TCollection::<anonymous>kIsOwner
private:
static TCollection*fgCurrentCollectionused by macro R__FOR_EACH
static Bool_tfgEmptyingGarbageused by garbage collector
static TObjectTable*fgGarbageCollectionused by garbage collector
static Int_tfgGarbageStackused by garbage collector

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

void AddAll(const TCollection* col)
 Add all objects from collection col to this collection.
void AddVector(TObject *va_(obj1), ...)
 Add all arguments to the collection. The list of objects must be
 temrinated by 0, e.g.: l.AddVector(o1, o2, o3, o4, 0);
Bool_t AssertClass(TClass* cl) const
 Make sure all objects in this collection inherit from class cl.
void Browse(TBrowser* b)
 Browse this collection (called by TBrowser).
 If b=0, there is no Browse call TObject::Browse(0) instead.
         This means TObject::Inspect() will be invoked indirectly
TObject * Clone(const char* newname = "") const
 Make a clone of an collection using the Streamer facility.
 If newname is specified, this will be the name of the new collection.
Int_t Compare(const TObject* obj) const
 Compare two TCollection objects. Returns 0 when equal, -1 when this is
 smaller and +1 when bigger (like strcmp()).
void Draw(Option_t* option = "")
 Draw all objects in this collection.
void Dump() const
 Dump all objects in this collection.
TObject * FindObject(const char* name) const
 Find an object in this collection using its name. Requires a sequential
 scan till the object has been found. Returns 0 if object with specified
 name is not found.
TObject * operator()(const char* name) const
 Find an object in this collection by name.
TObject * FindObject(const TObject* obj) const
 Find an object in this collection using the object's IsEqual()
 member function. Requires a sequential scan till the object has
 been found. Returns 0 if object is not found.
 Typically this function is overridden by a more efficient version
 in concrete collection classes (e.g. THashTable).
const char * GetName() const
 Return name of this collection.
 if no name, return the collection class name.
Int_t GrowBy(Int_t delta) const
 Increase the collection's capacity by delta slots.
Bool_t IsArgNull(const char* where, const TObject* obj) const
 Returns true if object is a null pointer.
void ls(Option_t* option = "") const
 List (ls) all objects in this collection.
 Wildcarding supported, eg option="xxx*" lists only objects
 with names xxx*.
void Paint(Option_t* option = "")
 Paint all objects in this collection.
void PrintCollectionHeader(Option_t* option) const
 Print the collection header.
const char* GetCollectionEntryName(TObject* entry) const
 For given collection entry return the string that is used to
 identify the object and, potentially, perform wildcard/regexp
 filtering on.
void PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
 Print the collection entry.
void Print(Option_t* option = "") const
 Defualt print for collections, calls Print(option, 1).
 This will print the collection header and Print() methods of
 all the collection entries.

 If you want to override Print() for a collection class, first
 see if you can accomplish it by overriding the following protected
 methods:
   void        PrintCollectionHeader(Option_t* option) const;
   const char* GetCollectionEntryName(TObject* entry) const;
   void        PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const;
 Otherwise override the Print(Option_t *option, Int_t)
 variant. Remember to declare:
   using TCollection::Print;
 somewhere close to the method declaration.
void Print(Option_t* option, Int_t recurse) const
 Print the collection header and its elements.

 If recurse is non-zero, descend into printing of
 collection-entries with recurse - 1.
 This means, if recurse is negative, the recursion is infinite.

 Option is passed recursively.
void Print(Option_t* option, const char* wildcard, Int_t recurse = 1) const
 Print the collection header and its elements that match the wildcard.

 If recurse is non-zero, descend into printing of
 collection-entries with recurse - 1.
 This means, if recurse is negative, the recursion is infinite.

 Option is passed recursively, but wildcard is only used on the
 first level.
void Print(Option_t* option, TPRegexp& regexp, Int_t recurse = 1) const
 Print the collection header and its elements that match the regexp.

 If recurse is non-zero, descend into printing of
 collection-entries with recurse - 1.
 This means, if recurse is negative, the recursion is infinite.

 Option is passed recursively, but regexp is only used on the
 first level.
void RecursiveRemove(TObject* obj)
 Remove object from this collection and recursively remove the object
 from all other objects (and collections).
void RemoveAll(TCollection* col)
 Remove all objects in collection col from this collection.
void Streamer(TBuffer& )
 Stream all objects in the collection to or from the I/O buffer.
Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
 Write all objects in this collection. By default all objects in
 the collection are written individually (each object gets its
 own key). Note, this is recursive, i.e. objects in collections
 in the collection are also written individually. To write all
 objects using a single key specify a name and set option to
 TObject::kSingleKey (i.e. 1).
Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
 Write all objects in this collection. By default all objects in
 the collection are written individually (each object gets its
 own key). Note, this is recursive, i.e. objects in collections
 in the collection are also written individually. To write all
 objects using a single key specify a name and set option to
 TObject::kSingleKey (i.e. 1).
TCollection * GetCurrentCollection()
 Return the globally accessible collection.
void SetCurrentCollection()
 Set this collection to be the globally accesible collection.
void StartGarbageCollection()
 Set up for garbage collection.
void EmptyGarbageCollection()
 Do the garbage collection.
void GarbageCollect(TObject* obj)
 Add to the list of things to be cleaned up.
void SetOwner(Bool_t enable = kTRUE)
 Set whether this collection is the owner (enable==true)
 of its content.  If it is the owner of its contents,
 these objects will be deleted whenever the collection itself
 is delete.   The objects might also be deleted or destructed when Clear
 is called (depending on the collection).
TIter begin() const
{ return ++(TIter(this)); }
TIter end() const
{ return TIter::End(); }
TCollection(const TCollection& )
void operator=(const TCollection& )
TCollection()
{ }
virtual ~TCollection()
{ }
void Add(TObject* obj)
Int_t Capacity() const
{ return fSize; }
void Clear(Option_t* option = "")
Bool_t Contains(const char* name) const
{ return FindObject(name) != 0; }
Bool_t Contains(const TObject* obj) const
{ return FindObject(obj) != 0; }
void Delete(Option_t* option = "")
Int_t GetEntries() const
{ return GetSize(); }
TObject ** GetObjectRef(const TObject* obj) const
Int_t GetSize() const
{ return fSize; }
ULong_t Hash() const
{ return fName.Hash(); }
Bool_t IsEmpty() const
{ return GetSize() <= 0; }
Bool_t IsFolder() const
{ return kTRUE; }
Bool_t IsOwner() const
{ return TestBit(kIsOwner); }
Bool_t IsSortable() const
{ return kTRUE; }
TIterator * MakeIterator(Bool_t dir = kIterForward) const
TIterator * MakeReverseIterator() const
TObject * Remove(TObject* obj)
void RemoveAll(TCollection* col)
void SetName(const char* name)
{ fName = name; }