library: libCore #include "TRefArray.h"

# TRefArrayIter

class description - source file - inheritance tree (.pdf)

## class TRefArrayIter : public TIterator

| Inheritance Chart:

`TIterator`

<-

`TRefArrayIter`

        private:

                        TRefArrayIter()

        public:

                                     TRefArrayIter(const TRefArray* arr, Bool_t dir = kIterForward)
                                     TRefArrayIter(const TRefArrayIter& iter)
                                     ~TRefArrayIter()
                      static TClass* Class()
          virtual const TCollection* GetCollection() const
                     virtual TClass* IsA() const
                    virtual TObject* Next()
                  virtual TIterator& operator=(const TIterator& rhs)
                      TRefArrayIter& operator=(const TRefArrayIter& rhs)
                        virtual void Reset()
                        virtual void ShowMembers(TMemberInspector& insp, char* parent)
                        virtual void Streamer(TBuffer& b)
                                void StreamerNVirtual(TBuffer& b)

### Data Members

        private:

          const TRefArray* fArray      array being iterated
                     Int_t fCursor     current position in array
                    Bool_t fDirection  iteration direction

## Class Description

     TRefArray

     An array of references to TObjects. The array expands automatically
     when  objects are added (shrinking can be done by hand using Expand()

     The TRefArray can be filled with:
         array.Add(obj)
         array.AddAt(obj,i)
         but not array[i] = obj  !!!

     The array elements can be retrieved with:
         TObject *obj = array.At(i);

     When a TRefArray is Streamed, only the pointer unique id is written,
     not the referenced object. TRefArray may be assigned to different
     branches of one Tree or several Trees.
     The branch containing the TRefArray can be read before or after the
     array (eg TClonesArray, STL vector,..) of the referenced objects.

     See an example in $ROOTSYS/test/Event.h

     RESTRICTIONS when using TRefArray
     ---------------------------------
      - Elements in a TRefArray cannot point to a TFile or TDirectory.
      - All elements of a TRefArray must be set in the same process,
        In particular, one cannot modify some elements of the array in
        a different process.
     Use an array of TRef when one of the above restrictions is met.

TRefArrayIter(const TRefArray *arr, Bool_t dir)

     Create array iterator. By default the iteration direction
     is kIterForward. To go backward use kIterBackward.

TRefArrayIter(const TRefArrayIter &iter) : TIterator(iter)

     Copy ctor.

TObject* Next()

     Return next object in array. Returns 0 when no more objects in array.

void Reset()

     Reset array iterator.

### Inline Functions

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

Author: Rene Brun 02/10/2001
Last update: root/cont:$Name: $:$Id: TRefArray.cxx,v 1.20 2005/03/26 07:02:14 brun Exp $
Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *