nested iterators

Sean Kelly (kelly@charm.physics.ucla.edu)
Mon, 8 Mar 1999 19:53:55 -0800 (PST)


Hi Rooters

My question is with regards to the correct way to implement nested
iterators.

In the code fragment below, it seems that inner loop iterator is
created many times, when all I really want to do is to reset it to
the new value of leafList.

Thanks for any advice.

Sean Kelly

TObjArray *branchList = ntuple->TTree::GetListOfBranches();
TObjArray *leafList;

TIter nextBranch(branchList);
while ( branch = (TBranch*) nextBranch() ) {
leafList = branch->GetListOfLeaves();
TIter nextLeaf(leafList);
while ( leaf = (TLeaf*) nextLeaf() ) {

// stuff

}
}