ROOT logo
ROOT » CORE » CONT » TList

class TList: public TSeqCollection


TList

A doubly linked list. All classes inheriting from TObject can be
inserted in a TList. Before being inserted into the list the object
pointer is wrapped in a TObjLink object which contains, besides
the object pointer also a previous and next pointer.

There are basically four ways to iterate over a TList (in order
of preference, if not forced by other constraints):
1) Using the R__FOR_EACH macro:
GetListOfPrimitives()->R__FOR_EACH(TObject,Paint)(option);

2) Using the TList iterator TListIter (via the wrapper class
TIter):
TIter next(GetListOfPrimitives());
while ((TObject *obj = next()))
obj->Draw(next.GetOption());

3) Using the TList iterator TListIter and std::for_each
algorithm:
 A function object, which will be applied to each element
 of the given range.
struct STestFunctor {
bool operator()(TObject *aObj) {

return true;
}
}


TIter iter(mylist);
for_each( iter.Begin(), TIter::End(), STestFunctor() );

4) Using the TObjLink list entries (that wrap the TObject*):
TObjLink *lnk = GetListOfPrimitives()->FirstLink();
while (lnk) {
lnk->GetObject()->Draw(lnk->GetOption());
lnk = lnk->Next();
}

5) Using the TList's After() and Before() member functions:
TFree *idcur = this;
while (idcur) {


idcur = (TFree*)GetListOfFree()->After(idcur);
}

Methods 2, 3 and 4 can also easily iterate backwards using either
a backward TIter (using argument kIterBackward) or by using
LastLink() and lnk->Prev() or by using the Before() member.
                           


This class is also known as (typedefs to this class)

TTabCom::TContainer

Function Members (Methods)

public:
TList()
TList(TObject*)
virtual~TList()
voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(TObject* obj)
virtual voidAdd(TObject* obj, Option_t* opt)
virtual voidAddAfter(const TObject* after, TObject* obj)
virtual voidAddAfter(TObjLink* after, TObject* obj)
virtual voidTCollection::AddAll(const TCollection* col)
virtual voidAddAt(TObject* obj, Int_t idx)
virtual voidAddBefore(const TObject* before, TObject* obj)
virtual voidAddBefore(TObjLink* before, TObject* obj)
virtual voidAddFirst(TObject* obj)
virtual voidAddFirst(TObject* obj, Option_t* opt)
virtual voidAddLast(TObject* obj)
virtual voidAddLast(TObject* obj, Option_t* opt)
voidTCollection::AddVector(TObject* obj1)
virtual TObject*After(const TObject* obj) const
virtual voidTObject::AppendPad(Option_t* option = "")
Bool_tTCollection::AssertClass(TClass* cl) const
virtual TObject*At(Int_t idx) const
virtual TObject*Before(const TObject* obj) const
virtual voidTCollection::Browse(TBrowser* b)
Int_tTCollection::Capacity() const
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidClear(Option_t* option = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTCollection::Compare(const TObject* obj) const
Bool_tTCollection::Contains(const char* name) const
Bool_tTCollection::Contains(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 voidTCollection::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTCollection::Dump() const
static voidTCollection::EmptyGarbageCollection()
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
virtual TObject*First() const
virtual TObjLink*FirstLink() const
static voidTCollection::GarbageCollect(TObject* obj)
static TCollection*TCollection::GetCurrentCollection()
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tTCollection::GetEntries() const
virtual const char*TObject::GetIconName() const
virtual const char*TCollection::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_tTCollection::GetSize() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Int_tTCollection::GrowBy(Int_t delta) const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTCollection::Hash() const
virtual Int_tTSeqCollection::IndexOf(const TObject* obj) 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_tTCollection::IsArgNull(const char* where, const TObject* obj) const
Bool_tIsAscending()
virtual Bool_tTCollection::IsEmpty() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTCollection::IsFolder() const
Bool_tTObject::IsOnHeap() const
Bool_tTCollection::IsOwner() const
virtual Bool_tTCollection::IsSortable() const
virtual Bool_tTSeqCollection::IsSorted() const
Bool_tTObject::IsZombie() const
virtual TObject*Last() const
Int_tTSeqCollection::LastIndex() const
virtual TObjLink*LastLink() const
virtual voidTCollection::ls(Option_t* option = "") const
virtual TIterator*MakeIterator(Bool_t dir = kIterForward) const
virtual TIterator*TCollection::MakeReverseIterator() const
voidTObject::MayNotUse(const char* method) const
Long64_tTSeqCollection::Merge(TCollection* list)
virtual Bool_tTObject::Notify()
static Int_tTSeqCollection::ObjCompare(TObject* a, TObject* b)
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static 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*TCollection::operator()(const char* name) const
virtual voidTCollection::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTCollection::Print(Option_t* option = "") const
virtual voidTCollection::Print(Option_t* option, Int_t recurse) const
virtual voidTCollection::Print(Option_t* option, const char* wildcard, Int_t recurse = 1) const
virtual voidTCollection::Print(Option_t* option, TPRegexp& regexp, Int_t recurse = 1) const
static voidTSeqCollection::QSort(TObject** a, Int_t first, Int_t last)
static voidTSeqCollection::QSort(TObject** a, TObject** b, Int_t first, Int_t last)
virtual Int_tTObject::Read(const char* name)
virtual voidRecursiveRemove(TObject* obj)
virtual TObject*Remove(TObject* obj)
virtual TObject*Remove(TObjLink* lnk)
virtual voidTSeqCollection::RemoveAfter(TObject* after)
voidTCollection::RemoveAll()
virtual voidTCollection::RemoveAll(TCollection* col)
virtual TObject*TSeqCollection::RemoveAt(Int_t idx)
virtual voidTSeqCollection::RemoveBefore(TObject* before)
virtual voidTSeqCollection::RemoveFirst()
virtual voidTSeqCollection::RemoveLast()
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidTCollection::SetCurrentCollection()
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidTCollection::SetName(const char* name)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTCollection::SetOwner(Bool_t enable = kTRUE)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidSort(Bool_t order = kSortAscending)
static voidTCollection::StartGarbageCollection()
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& 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
voidTSeqCollection::UnSort()
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTCollection::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTCollection::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTSeqCollection::Changed()
virtual voidDeleteLink(TObjLink* lnk)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
TObjLink**DoSort(TObjLink** head, Int_t n)
TObjLink*FindLink(const TObject* obj, Int_t& idx) const
virtual const char*TCollection::GetCollectionEntryName(TObject* entry) const
TObjLink*LinkAt(Int_t idx) const
Bool_tLnkCompare(TObjLink* l1, TObjLink* l2)
voidTObject::MakeZombie()
virtual TObjLink*NewLink(TObject* obj, TObjLink* prev = NULL)
virtual TObjLink*NewOptLink(TObject* obj, Option_t* opt, TObjLink* prev = NULL)
virtual voidTCollection::PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
virtual voidTCollection::PrintCollectionHeader(Option_t* option) const
private:
TList(const TList&)
TList&operator=(const TList&)

Data Members

protected:
Bool_tfAscending! sorting order (when calling Sort() or for TSortedList)
TObjLink*fCache! cache to speedup sequential calling of Before() and After() functions
TObjLink*fFirst! pointer to first entry in linked list
TObjLink*fLast! pointer to last entry in linked list
TStringTCollection::fNamename of the collection
Int_tTCollection::fSizenumber of elements in collection
Bool_tTSeqCollection::fSortedtrue if collection has been sorted

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

~TList()
 Delete the list. Objects are not deleted unless the TList is the
 owner (set via SetOwner()).
void AddFirst(TObject* obj)
 Add object at the beginning of the list.
void AddFirst(TObject* obj, Option_t* opt)
 Add object at the beginning of the list and also store option.
 Storing an option is useful when one wants to change the behaviour
 of an object a little without having to create a complete new
 copy of the object. This feature is used, for example, by the Draw()
 method. It allows the same object to be drawn in different ways.
void AddLast(TObject* obj)
 Add object at the end of the list.
void AddLast(TObject* obj, Option_t* opt)
 Add object at the end of the list and also store option.
 Storing an option is useful when one wants to change the behaviour
 of an object a little without having to create a complete new
 copy of the object. This feature is used, for example, by the Draw()
 method. It allows the same object to be drawn in different ways.
void AddBefore(const TObject *before, TObject *obj)
 Insert object before object before in the list.
void AddBefore(TObjLink *before, TObject *obj)
 Insert object before the specified ObjLink object. If before = 0 then add
 to the head of the list. An ObjLink can be obtained by looping over a list
 using the above describe iterator method 3.
void AddAfter(const TObject *after, TObject *obj)
 Insert object after object after in the list.
void AddAfter(TObjLink *after, TObject *obj)
 Insert object after the specified ObjLink object. If after = 0 then add
 to the tail of the list. An ObjLink can be obtained by looping over a list
 using the above describe iterator method 3.
void AddAt(TObject* obj, Int_t idx)
 Insert object at position idx in the list.
TObject * After(const TObject* obj) const
 Returns the object after object obj. Obj is found using the
 object's IsEqual() method.  Returns 0 if obj is last in list.
TObject * At(Int_t idx) const
 Returns the object at position idx. Returns 0 if idx is out of range.
TObject * Before(const TObject* obj) const
 Returns the object before object obj. Obj is found using the
 object's IsEqual() method.  Returns 0 if obj is first in list.
void Clear(Option_t* option = "")
 Remove all objects from the list. Does not delete the objects
 unless the TList is the owner (set via SetOwner()) and option
 "nodelete" is not set.
 If option="nodelete" then don't delete any heap objects that were
 marked with the kCanDelete bit, otherwise these objects will be
 deleted (this option is used by THashTable::Clear()).
void Delete(Option_t* option = "")
 Remove all objects from the list AND delete all heap based objects.
 If option="slow" then keep list consistent during delete. This allows
 recursive list operations during the delete (e.g. during the dtor
 of an object in this list one can still access the list to search for
 other not yet deleted objects).
void DeleteLink(TObjLink* lnk)
 Delete a TObjLink object.
TObject * FindObject(const char *name)
 Find an object in this list using its name. Requires a sequential
 scan till the object has been found. Returns 0 if object with specified
 name is not found. This method overrides the generic FindObject()
 of TCollection for efficiency reasons.
TObject * FindObject(const TObject *obj)
 Find an object in this list using the object's IsEqual()
 member function. Requires a sequential scan till the object has
 been found. Returns 0 if object is not found.
 This method overrides the generic FindObject() of TCollection for
 efficiency reasons.
TObjLink * FindLink(const TObject* obj, Int_t& idx) const
 Returns the TObjLink object that contains object obj. In idx it returns
 the position of the object in the list.
TObject * First() const
 Return the first object in the list. Returns 0 when list is empty.
TObject ** GetObjectRef(const TObject* obj) const
 Return address of pointer to obj
TObject * Last() const
 Return the last object in the list. Returns 0 when list is empty.
TObjLink * LinkAt(Int_t idx) const
 Return the TObjLink object at index idx.
TIterator * MakeIterator(Bool_t dir = kIterForward) const
 Return a list iterator.
TObjLink * NewLink(TObject* obj, TObjLink* prev = NULL)
 Return a new TObjLink.
TObjLink * NewOptLink(TObject* obj, Option_t* opt, TObjLink* prev = NULL)
 Return a new TObjOptLink (a TObjLink that also stores the option).
void RecursiveRemove(TObject* obj)
 Remove object from this collection and recursively remove the object
 from all other objects (and collections).
TObject * Remove(TObject *obj)
 Remove object from the list.
TObject * Remove(TObjLink *lnk)
 Remove object link (and therefore the object it contains)
 from the list.
void Sort(Bool_t order = kSortAscending)
 Sort linked list. Real sorting is done in private function DoSort().
 The list can only be sorted when is contains objects of a sortable
 class.
Bool_t LnkCompare(TObjLink* l1, TObjLink* l2)
 Compares the objects stored in the TObjLink objects.
 Depending on the flag IsAscending() the function returns
 true if the object in l1 <= l2 (ascending) or l2 <= l1 (descending).
TObjLink ** DoSort(TObjLink** head, Int_t n)
 Sort linked list.
void Streamer(TBuffer& b)
 Stream all objects in the collection to or from the I/O buffer.
TList(const TList&)
TList& operator=(const TList& )
TList()
{ }
TList(TObject *)
{ }
void Add(TObject* obj)
{ AddLast(obj); }
void Add(TObject* obj, Option_t* opt)
{ AddLast(obj, opt); }
TObjLink * FirstLink() const
{ return fFirst; }
TObjLink * LastLink() const
{ return fLast; }
Bool_t IsAscending()
{ return fAscending; }