当前位置: 首页>>代码示例>>C++>>正文


C++ TMap::MakeIterator方法代码示例

本文整理汇总了C++中TMap::MakeIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ TMap::MakeIterator方法的具体用法?C++ TMap::MakeIterator怎么用?C++ TMap::MakeIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TMap的用法示例。


在下文中一共展示了TMap::MakeIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WriteMergeObjects

void WriteMergeObjects( TFile *target ) {
  cout << "Writing the merged data." << endl;

  TIterator *nextobj = MergeObjects.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TObject *obj = MergeObjects.GetValue(pathname_obj);
    target->cd(path);

    obj->Write( name );

    delete obj;
  }
  MergeObjects.Clear();

  target->Write();

  // Temporarily let multiple root files remain if > 2GB
  // Prevent Target_1.root Target_2.root, ... from happening.
  //  long long max_tree_size = 200000000000LL; // 200 GB
  //  if(TTree::GetMaxTreeSize() < max_tree_size ) {
  //    TTree::SetMaxTreeSize(max_tree_size);
  //  }

  nextobj = MergeChains.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TChain *ch = (TChain *)MergeChains.GetValue(pathname_obj);
    target->cd(path);
    ch->Merge(target,0,"KEEP");

    delete ch;

	// in case of multiple objects with same pathname, must remove
	// this one from the list so we don't get the same (deleted)
	// one next time we look up the same name
	MergeChains.Remove(pathname_obj);
  }
  MergeChains.Clear();

  InitializedMergeObjects = false;
}
开发者ID:ekfriis,项目名称:farmout,代码行数:48,代码来源:mergeFiles.C

示例2: MergeRootfile

void MergeRootfile( TDirectory *target, TString source_name ) {

  TFile *source = NULL;
  if( !InitializedMergeObjects ) {
    InitializedMergeObjects = true;
    source = TFile::Open(source_name);
    cout << "Initializing merge objects from " << source_name << endl;
    InitMergeObjects( target, source );
    delete source;
    return;
  }

  // loop over all objects to be merged
  TIterator *nextobj = MergeObjects.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TObject *obj = MergeObjects.GetValue(pathname_obj);

    if ( obj->IsA()->InheritsFrom( "TH1" ) ) {
      // descendant of TH1 -> merge it

      TH1 *h1 = (TH1*)obj;

      if( !source ) {
        source = TFile::Open(source_name);
      }
      // make sure we are at the correct directory level by cd'ing to path
      source->cd( path );
      TH1 *h2 = (TH1*)gDirectory->Get( h1->GetName() );
      if ( h2 ) {
        h1->Add( h2 );
        delete h2;
      }
    }
  }

  delete nextobj;
  nextobj = NULL;

  // loop over all chains to be merged
  nextobj = MergeChains.MakeIterator();
  TObjString *pathname_obj;
  while( (pathname_obj = (TObjString *)nextobj->Next()) ) {
    TString path,name;
    SplitPathName(pathname_obj->String(),&path,&name);

    TChain *ch = (TChain *)MergeChains.GetValue(pathname_obj);

    ch->Add(source_name);
  }

  delete nextobj;
  nextobj = NULL;

  if( source ) {
    delete source;
  }
}
开发者ID:ekfriis,项目名称:farmout,代码行数:61,代码来源:mergeFiles.C


注:本文中的TMap::MakeIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。