TListIter


class description - source file - inheritance tree

class TListIter : public TIterator

    private:
TListIter TListIter() public:
TListIter TListIter(const TList* l, Bool_t dir = kIterForward) TListIter TListIter(const TListIter& iter) virtual void ~TListIter() TClass* Class() virtual const TCollection* GetCollection() const virtual Option_t* GetOption() const virtual TClass* IsA() const virtual TObject* Next() TListIter& operator=(const TListIter& rhs) virtual TIterator& operator=(const TIterator& rhs) virtual void Reset() void SetOption(Option_t* option) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b)

Data Members

private:
const TList* fList list being iterated TObjLink* fCurCursor current position in list TObjLink* fCursor next position in list Bool_t fDirection iteration direction Bool_t fStarted iteration started

Class Description

                                                                      
 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 ForEach macro:                                       
         GetListOfPrimitives()->ForEach(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.        
                             
                                                                      


TListIter(const TList *l, Bool_t dir) : fList(l), fCurCursor(0), fCursor(0), fDirection(dir), fStarted(kFALSE)
 Create a new list iterator. By default the iteration direction
 is kIterForward. To go backward use kIterBackward.

TListIter(const TListIter &iter)
 Copy ctor.

TObject* Next()
 Return next object in the list. Returns 0 when no more objects in list.

Option_t* GetOption() const
 Returns the object option stored in the list.

void SetOption(Option_t *option)
 Sets the object option stored in the list.



Inline Functions


                 TListIter TListIter(const TListIter& iter)
                TIterator& operator=(const TIterator& rhs)
                TListIter& operator=(const TListIter& rhs)
        const TCollection* GetCollection() const
                      void Reset()
                   TClass* Class()
                   TClass* IsA() const
                      void ShowMembers(TMemberInspector& insp, char* parent)
                      void Streamer(TBuffer& b)
                      void ~TListIter()


Author: Fons Rademakers 10/08/95
Last update: 2.23/08 01/11/99 21.38.07 by Fons Rademakers
Copyright (c) 1995-1999, The ROOT System, All rights reserved. *


ROOT page - Class index - 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.