FEDRA emulsion software from the OPERA Collaboration
TIndexCellIter Class Reference

IndexCell iterator. More...

#include <TIndexCell.h>

Inheritance diagram for TIndexCellIter:
Collaboration diagram for TIndexCellIter:

Public Member Functions

const TIndexCellGetCell () const
 
int LevelDown ()
 
TIndexCell const * Next ()
 
void Reset ()
 
void Test ()
 
 TIndexCellIter (const TIndexCell *cell, int level, Bool_t dir=kIterForward)
 
 ~TIndexCellIter ()
 

Private Member Functions

 TIndexCellIter ()
 

Private Attributes

const TIndexCellfCell
 cell being iterated More...
 
Bool_t fDirection
 iteration direction More...
 
Int_t fLevel
 current level More...
 
Int_t fLevel0
 level to be iterated on More...
 
Int_t fPass
 number of cells iterated More...
 
Int_t * fVind
 current position in array More...
 

Detailed Description

IndexCell iterator.

Constructor & Destructor Documentation

◆ TIndexCellIter() [1/2]

TIndexCellIter::TIndexCellIter ( )
inlineprivate
121: fCell(0) { }
const TIndexCell * fCell
cell being iterated
Definition: TIndexCell.h:114

◆ TIndexCellIter() [2/2]

TIndexCellIter::TIndexCellIter ( const TIndexCell cell,
int  level,
Bool_t  dir = kIterForward 
)

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

640{
643
644 fPass = 0;
645 fCell = cell;
646 fDirection = dir;
647 if( level > fCell->Nlevels() ) level=0;
648 if( level < 1 ) level=0;
649 fLevel = fLevel0 = level-1;
650 if(fLevel0 >= 0) {
651 fVind = new int[ fLevel0+1 ];
652 Reset();
653 }
654}
Int_t fPass
number of cells iterated
Definition: TIndexCell.h:118
Int_t * fVind
current position in array
Definition: TIndexCell.h:115
Int_t fLevel
current level
Definition: TIndexCell.h:117
Int_t fLevel0
level to be iterated on
Definition: TIndexCell.h:116
void Reset()
Definition: TIndexCell.cpp:705
Bool_t fDirection
iteration direction
Definition: TIndexCell.h:119
Int_t Nlevels() const
Definition: TIndexCell.cpp:328

◆ ~TIndexCellIter()

TIndexCellIter::~TIndexCellIter ( )
658{
659 if(fVind) delete [] fVind;
660 fVind=0;
661}

Member Function Documentation

◆ GetCell()

const TIndexCell * TIndexCellIter::GetCell ( ) const
inline
132{ return fCell; }

◆ LevelDown()

int TIndexCellIter::LevelDown ( )
689{
690 if(fLevel<1) return 0;
691 fVind[fLevel] = 0;
692 fLevel--;
693 int nent = fCell->At(fLevel,fVind)->GetEntries();
694 //printf("LevelDown: level = %d, nent= %d fVind= %d\n",fLevel, nent,fVind[fLevel]);
695 if( fVind[fLevel] < nent-1 ) {
696 fVind[fLevel]++;
698 fVind[fLevel0]=-1;
699 return 1;
700 } else return LevelDown();
701 return 0;
702}
int LevelDown()
Definition: TIndexCell.cpp:688
Int_t GetEntries() const
Definition: TIndexCell.h:82
TIndexCell const * At(Int_t narg, Int_t vind[]) const
Definition: TIndexCell.cpp:519

◆ Next()

TIndexCell const * TIndexCellIter::Next ( )

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

665{
667
668 if( fLevel0 <0 ) return 0;
669
670 START:
671
672 if( fLevel != fLevel0 ) return 0;
673
674 int nent = fCell->At(fLevel,fVind)->GetEntries();
675 //printf("Next: nent= %d fPass= %d\n",nent,fPass);
676
677 if( fVind[fLevel] < nent-1 ) {
678 fVind[fLevel]++;
679 fPass++;
680 return fCell->At(fLevel+1,fVind);
681 } else {
682 if( LevelDown() ) goto START;
683 }
684 return 0;
685}

◆ Reset()

void TIndexCellIter::Reset ( )

Reset array iterator.

706{
708
709 if (fDirection == kIterForward) {
710 fLevel = fLevel0;
711 for(int i=0; i<fLevel0; i++ ) fVind[i]=0;
712 fVind[fLevel0]=-1;
713 }
714 else {}
715}

◆ Test()

void TIndexCellIter::Test ( )
719{
720 int count=0;
721 while( Next() ) count++;
722 printf("count = %d\n",count);
723}
TIndexCell const * Next()
Definition: TIndexCell.cpp:664

Member Data Documentation

◆ fCell

const TIndexCell* TIndexCellIter::fCell
private

cell being iterated

◆ fDirection

Bool_t TIndexCellIter::fDirection
private

iteration direction

◆ fLevel

Int_t TIndexCellIter::fLevel
private

current level

◆ fLevel0

Int_t TIndexCellIter::fLevel0
private

level to be iterated on

◆ fPass

Int_t TIndexCellIter::fPass
private

number of cells iterated

◆ fVind

Int_t* TIndexCellIter::fVind
private

current position in array


The documentation for this class was generated from the following files: