nested iterators

From: Sean Kelly (kelly@charm.physics.ucla.edu)
Date: Tue Mar 09 1999 - 04:53:55 MET


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

    }
  }



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET