library: libCore #include "TList.h" |
TList
class description - header file - source file - inheritance tree (.pdf)
protected:
TList(const TList&)
virtual void DeleteLink(TObjLink* lnk)
TObjLink** DoSort(TObjLink** head, Int_t n)
TObjLink* FindLink(const TObject* obj, Int_t& idx) const
TObjLink* LinkAt(Int_t idx) const
Bool_t LnkCompare(TObjLink* l1, TObjLink* l2)
virtual TObjLink* NewLink(TObject* obj, TObjLink* prev = 0)
virtual TObjLink* NewOptLink(TObject* obj, Option_t* opt, TObjLink* prev = 0)
TList& operator=(const TList&)
public:
TList()
TList(TObject*)
virtual ~TList()
virtual void Add(TObject* obj)
virtual void Add(TObject* obj, Option_t* opt)
virtual void AddAfter(const TObject* after, TObject* obj)
virtual void AddAfter(TObjLink* after, TObject* obj)
virtual void AddAt(TObject* obj, Int_t idx)
virtual void AddBefore(const TObject* before, TObject* obj)
virtual void AddBefore(TObjLink* before, TObject* obj)
virtual void AddFirst(TObject* obj)
virtual void AddFirst(TObject* obj, Option_t* opt)
virtual void AddLast(TObject* obj)
virtual void AddLast(TObject* obj, Option_t* opt)
virtual TObject* After(const TObject* obj) const
virtual TObject* At(Int_t idx) const
virtual TObject* Before(const TObject* obj) const
static TClass* Class()
virtual void Clear(Option_t* option = "")
virtual void Delete(Option_t* option = "")
virtual TObject* FindObject(const char* name) const
virtual TObject* FindObject(const TObject* obj) const
virtual TObject* First() const
virtual TObjLink* FirstLink() const
virtual TObject** GetObjectRef(const TObject* obj) const
virtual TClass* IsA() const
Bool_t IsAscending()
virtual TObject* Last() const
virtual TObjLink* LastLink() const
virtual TIterator* MakeIterator(Bool_t dir = kIterForward) const
virtual TObject* Remove(TObject* obj)
virtual TObject* Remove(TObjLink* lnk)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Sort(Bool_t order = kSortAscending)
virtual void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
protected:
TObjLink* fFirst ! pointer to first entry in linked list
TObjLink* fLast ! pointer to last entry in linked list
TObjLink* fCache ! cache to speedup sequential calling of Before() and After() functions
Bool_t fAscending ! sorting order (when calling Sort() or for TSortedList)
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 TObjLink list entries (that wrap the TObject*):
TObjLink *lnk = GetListOfPrimitives()->FirstLink();
while (lnk) {
lnk->GetObject()->Draw(lnk->GetOption());
lnk = lnk->Next();
}
4) 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.
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, 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(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(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.
TObject * After(const TObject *obj)
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)
Returns the object at position idx. Returns 0 if idx is out of range.
TObject * Before(const TObject *obj)
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).
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)
Returns the TObjLink object that contains object obj. In idx it returns
the position of the object in the list.
TObject * First()
Return the first object in the list. Returns 0 when list is empty.
TObject * Last()
Return the last object in the list. Returns 0 when list is empty.
TObjLink * LinkAt(Int_t idx)
Return the TObjLink object at index idx.
TObjLink * NewLink(TObject *obj, TObjLink *prev)
Return a new TObjLink.
TObjLink * NewOptLink(TObject *obj, Option_t *opt, TObjLink *prev)
Return a new TObjOptLink (a TObjLink that also stores the option).
TObject * Remove(TObjLink *lnk)
Remove object link (and therefore the object it contains)
from the list.
void Sort(Bool_t order)
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).
void Streamer(TBuffer &b)
Stream all objects in the collection to or from the I/O buffer.
Author: Fons Rademakers 10/08/95
Last update: root/cont:$Name: $:$Id: TList.cxx,v 1.21 2006/07/09 05:27:53 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.