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.