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


C++ DataSetList::begin方法代码示例

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


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

示例1:

// DataIO_Std::WriteData3D()
int DataIO_Std::WriteData3D( CpptrajFile& file, DataSetList const& setList) 
{
  int err = 0;
  for (DataSetList::const_iterator set = setList.begin(); set != setList.end(); ++set)
  {
    if (set != setList.begin()) file.Printf("\n");
    err += WriteSet3D( *(*set), file );
  }
  return err;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:11,代码来源:DataIO_Std.cpp

示例2: ChangeOutputFormat

// Exec_DataSetCmd::ChangeOutputFormat()
Exec::RetType Exec_DataSetCmd::ChangeOutputFormat(CpptrajState const& State, ArgList& argIn)
{
  TextFormat::FmtType fmt;
  if (argIn.hasKey("double"))
    fmt = TextFormat::DOUBLE;
  else if (argIn.hasKey("scientific"))
    fmt = TextFormat::SCIENTIFIC;
  else if (argIn.hasKey("general"))
    fmt = TextFormat::GDOUBLE;
  else {
    mprinterr("Error: Expected either 'double', 'scientific', or 'general'\n");
    return CpptrajState::ERR;
  }
  // Loop over all DataSet arguments 
  std::string ds_arg = argIn.GetStringNext();
  while (!ds_arg.empty()) {
    DataSetList dsl = State.DSL().GetMultipleSets( ds_arg );
    for (DataSetList::const_iterator ds = dsl.begin(); ds != dsl.end(); ++ds)
      if ((*ds)->SetupFormat().SetFormatType(fmt))
        mprintf("\tSet '%s' output format changed to '%s'\n",
                (*ds)->legend(), TextFormat::typeDescription(fmt));
    ds_arg = argIn.GetStringNext();
  }
  return CpptrajState::OK;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:26,代码来源:Exec_DataSetCmd.cpp

示例3:

// Array1D::AddDataSets()
int Array1D::AddDataSets(DataSetList const& SetList) {
  for (DataSetList::const_iterator ds = SetList.begin(); ds != SetList.end(); ++ds)
    if ( push_back( *ds ) ) {
      array_.clear();
      return 1;
    }
  return 0;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:9,代码来源:Array1D.cpp

示例4: Execute

// Exec_SortEnsembleData::Execute()
Exec::RetType Exec_SortEnsembleData::Execute(CpptrajState& State, ArgList& argIn)
{
  debug_ = State.Debug();
  DataSetList setsToSort;
  std::string dsarg = argIn.GetStringNext();
  while (!dsarg.empty()) {
    setsToSort += State.DSL().GetMultipleSets( dsarg );
    dsarg = argIn.GetStringNext();
  }

  int err = 0;
# ifdef MPI
  // For now, require ensemble mode in parallel.
  if (!Parallel::EnsembleIsSetup()) {
    rprinterr("Error: Data set ensemble sort requires ensemble mode in parallel.\n");
    return CpptrajState::ERR;
  }
  // Only TrajComm masters have complete data.
  if (Parallel::TrajComm().Master()) {
    comm_ = Parallel::MasterComm();
# endif
    DataSetList OutputSets;
    err = SortData( setsToSort, OutputSets );
    if (err == 0) {
      // Remove unsorted sets. 
      for (DataSetList::const_iterator ds = setsToSort.begin(); ds != setsToSort.end(); ++ds)
        State.DSL().RemoveSet( *ds );
      // Add sorted sets.
      for (DataSetList::const_iterator ds = OutputSets.begin(); ds != OutputSets.end(); ++ds)
        State.DSL().AddSet( *ds );
      // Since sorted sets have been transferred to master DSL, OutputSets now
      // just has copies.
      OutputSets.SetHasCopies( true );
      mprintf("\tSorted sets:\n");
      OutputSets.List();
    }
# ifdef MPI
  }
  if (Parallel::World().CheckError( err ))
# else
  if (err != 0) 
# endif
    return CpptrajState::ERR;
  return CpptrajState::OK;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:46,代码来源:Exec_SortEnsembleData.cpp

示例5: GetSetsOfType

// DataSetList::GetSetsOfType()
DataSetList DataSetList::GetSetsOfType( std::string const& dsargIn, DataSet::DataType typeIn ) const
{
  DataSetList dsetOut;
  dsetOut.hasCopies_ = true;
  DataSetList selected = SelectSets(dsargIn);
  for (const_iterator ds = selected.begin(); ds != selected.end(); ++ds)
    if ( (*ds)->Type() == typeIn )
      dsetOut.Push_Back( *ds );
  return dsetOut;
}
开发者ID:hainm,项目名称:cpptraj,代码行数:11,代码来源:DataSetList.cpp

示例6: SetPrecisionOfDataSets

// DataSetList::SetPrecisionOfDataSets()
void DataSetList::SetPrecisionOfDataSets(std::string const& nameIn, int widthIn,
                                         int precisionIn)
{
  if (widthIn < 1)
    mprinterr("Error: Invalid data width (%i)\n", widthIn);
  else {
    DataSetList Sets = GetMultipleSets( nameIn );
    for (DataSetList::const_iterator ds = Sets.begin(); ds != Sets.end(); ++ds)
      (*ds)->SetupFormat().SetFormatWidthPrecision(widthIn, precisionIn);
  }
}
开发者ID:yuqinc,项目名称:cpptraj,代码行数:12,代码来源:DataSetList.cpp

示例7: mprintf

// Array1D::AddTorsionSets()
int Array1D::AddTorsionSets(DataSetList const& SetList) {
  // Ensure data sets are 1D and periodic
  for (DataSetList::const_iterator ds = SetList.begin(); ds != SetList.end(); ++ds) {
    if ( (*ds)->Meta().IsTorsionArray()) {
      if ( push_back( *ds ) ) {
        array_.clear();
        return 1;
      }
    } else
        mprintf("Warning: Set '%s' is not periodic, skipping.\n", (*ds)->legend());
  }
  return 0;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:14,代码来源:Array1D.cpp

示例8: mprinterr

// DataIO_CCP4::WriteData()
int DataIO_CCP4::WriteData(FileName const& fname, DataSetList const& setList)
{
    // Open output file
    CpptrajFile outfile;
    if (outfile.OpenWrite(fname)) {
        mprinterr("Error: Could not open CCP4 output file '%s'.\n", fname.full());
        return 1;
    }
    // Warn about writing multiple sets
    if (setList.size() > 1)
        mprintf("Warning: %s: Writing multiple 3D sets in CCP4 format not supported.\n"
                "Warning:   Only writing first set.\n", fname.full());
    return WriteSet3D( setList.begin(), outfile );
}
开发者ID:hainm,项目名称:cpptraj,代码行数:15,代码来源:DataIO_CCP4.cpp

示例9: WriteData

// DataIO_OpenDx::WriteData()
int DataIO_OpenDx::WriteData(FileName const& fname, DataSetList const& setList)
{
  // Open output file
  CpptrajFile outfile;
  if (outfile.OpenWrite(fname)) {
    mprinterr("Error: Could not open OpenDX output file.\n");
    return 1;
  }
  // Warn about writing multiple sets
  if (setList.size() > 1)
    mprintf("Warning: %s: Writing multiple 3D sets in OpenDX format may result in unexpected behavior\n", fname.full());
  int err = 0;
  for (DataSetList::const_iterator set = setList.begin(); set != setList.end(); ++set)
    err += WriteSet3D( *(*set), outfile );
  return err;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:17,代码来源:DataIO_OpenDx.cpp

示例10: Concatenate

// Exec_DataSetCmd::Concatenate()
Exec::RetType Exec_DataSetCmd::Concatenate(CpptrajState& State, ArgList& argIn) {
  std::string name = argIn.GetStringKey("name");
  bool use_offset = !argIn.hasKey("nooffset");
  DataSet* ds3 = State.DSL().AddSet( DataSet::XYMESH, name, "CAT" );
  if (ds3 == 0) return CpptrajState::ERR;
  DataSet_1D& out = static_cast<DataSet_1D&>( *ds3 );
  mprintf("\tConcatenating sets into '%s'\n", out.legend());
  if (use_offset)
    mprintf("\tX values will be offset.\n");
  else
    mprintf("\tX values will not be offset.\n");
  std::string dsarg = argIn.GetStringNext();
  double offset = 0.0;
  while (!dsarg.empty()) {
    DataSetList dsl = State.DSL().GetMultipleSets( dsarg );
    double XY[2];
    for (DataSetList::const_iterator ds = dsl.begin(); ds != dsl.end(); ++ds)
    {
      if ( (*ds)->Group() != DataSet::SCALAR_1D )
      {
        mprintf("Warning: '%s': Concatenation only supported for 1D scalar data sets.\n",
                (*ds)->legend());
      } else {
        DataSet_1D const& set = static_cast<DataSet_1D const&>( *(*ds) );
        mprintf("\t\t'%s'\n", set.legend());
        for (size_t i = 0; i != set.Size(); i++) {
          XY[0] = set.Xcrd( i ) + offset;
          XY[1] = set.Dval( i );
          out.Add( i, XY ); // NOTE: value of i does not matter for mesh
        }
        if (use_offset) offset = XY[0];
      }
    }
    dsarg = argIn.GetStringNext();
  }
  return CpptrajState::OK;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:38,代码来源:Exec_DataSetCmd.cpp

示例11: WriteCmatrix

// DataIO_Std::WriteCmatrix()
int DataIO_Std::WriteCmatrix(CpptrajFile& file, DataSetList const& Sets) {
  for (DataSetList::const_iterator ds = Sets.begin(); ds != Sets.end(); ++ds)
  {
    if ( (*ds)->Group() != DataSet::CLUSTERMATRIX) {
      mprinterr("Error: Write of cluster matrix and other sets to same file not supported.\n"
                "Error: Skipping '%s'\n", (*ds)->legend());
      continue;
    }
    DataSet_Cmatrix const& cm = static_cast<DataSet_Cmatrix const&>( *(*ds) );
    int nrows = cm.OriginalNframes();
    int col_width = std::max(3, DigitWidth( nrows ) + 1);
    int dat_width = std::max(cm.Format().Width(), (int)cm.Meta().Legend().size()) + 1;
    WriteNameToBuffer(file, "F1",               col_width, true);
    WriteNameToBuffer(file, "F2",               col_width, false);
    WriteNameToBuffer(file, cm.Meta().Legend(), dat_width, false);
    if (cm.SieveType() != ClusterSieve::NONE)
      file.Printf(" nframes %i", cm.OriginalNframes());
    file.Printf("\n");
    TextFormat col_fmt(TextFormat::INTEGER, col_width);
    TextFormat dat_fmt = cm.Format();
    dat_fmt.SetFormatAlign(TextFormat::RIGHT);
    dat_fmt.SetFormatWidth( dat_width );
    std::string total_fmt = col_fmt.Fmt() + col_fmt.Fmt() + dat_fmt.Fmt() + "\n";
    //mprintf("DEBUG: format '%s'\n", total_fmt.c_str());
    ClusterSieve::SievedFrames const& frames = cm.FramesToCluster();
    int ntotal = (int)frames.size();
    for (int idx1 = 0; idx1 != ntotal; idx1++) {
      int row = frames[idx1];
      for (int idx2 = idx1 + 1; idx2 != ntotal; idx2++) {
        int col = frames[idx2];
        file.Printf(total_fmt.c_str(), row+1, col+1, cm.GetFdist(col, row)); 
      }
    }
  }
  return 0;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:37,代码来源:DataIO_Std.cpp

示例12: WriteDataInverted

// DataIO_Std::WriteDataInverted()
int DataIO_Std::WriteDataInverted(CpptrajFile& file, DataSetList const& Sets)
{
  if (Sets.empty() || CheckAllDims(Sets, 1)) return 1;
  // Determine size of largest DataSet.
  size_t maxFrames = DetermineMax( Sets );
  // Write each set to a line.
  DataSet::SizeArray positions(1);
  // Set up x column format
  DataSetList::const_iterator set = Sets.begin();
  TextFormat x_col_format;
  if (hasXcolumn_)
    x_col_format = XcolFmt();
  else
    x_col_format = (*set)->Format();
  for (; set != Sets.end(); ++set) {
    // Write dataset name as first column.
    WriteNameToBuffer( file, (*set)->Meta().Legend(), x_col_format.ColumnWidth(), false); 
    // Write each frame to subsequent columns
    for (positions[0] = 0; positions[0] < maxFrames; positions[0]++) 
      (*set)->WriteBuffer(file, positions);
    file.Printf("\n");
  }
  return 0;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:25,代码来源:DataIO_Std.cpp

示例13: Setup

Analysis::RetType Analysis_AutoCorr::Setup(ArgList& analyzeArgs, AnalysisSetup& setup, int debugIn)
{
  const char* calctype;

  std::string setname = analyzeArgs.GetStringKey("name");
  DataFile* outfile = setup.DFL().AddDataFile( analyzeArgs.GetStringKey("out"), analyzeArgs );
  lagmax_ = analyzeArgs.getKeyInt("lagmax",-1);
  calc_covar_ = !analyzeArgs.hasKey("nocovar");
  usefft_ = !analyzeArgs.hasKey("direct");
  // Select datasets from remaining args
  dsets_.clear();
  ArgList dsetArgs = analyzeArgs.RemainingArgs();
  for (ArgList::const_iterator dsa = dsetArgs.begin(); dsa != dsetArgs.end(); ++dsa) {
    DataSetList setsIn = setup.DSL().GetMultipleSets( *dsa );
    for (DataSetList::const_iterator ds = setsIn.begin(); ds != setsIn.end(); ++ds) {
      if ( (*ds)->Group() != DataSet::SCALAR_1D && (*ds)->Type() != DataSet::VECTOR )
        mprintf("Warning: Set '%s' type not supported in AUTOCORR - skipping.\n",
                (*ds)->legend());
      else
        dsets_.push_back( *ds );
    }
  }
  if (dsets_.empty()) {
    mprinterr("Error: No data sets selected.\n");
    return Analysis::ERR;
  }
  // If setname is empty generate a default name
  if (setname.empty())
    setname = setup.DSL().GenerateDefaultName( "autocorr" );
  // Setup output datasets
  MetaData md( setname );
  for (unsigned int idx = 0; idx != dsets_.size(); idx++) {
    md.SetIdx( idx );
    DataSet* dsout = setup.DSL().AddSet( DataSet::DOUBLE, md );
    if (dsout==0) return Analysis::ERR;
    dsout->SetLegend( dsets_[idx]->Meta().Legend() );
    outputData_.push_back( dsout );
    // Add set to output file
    if (outfile != 0) outfile->AddDataSet( outputData_.back() );
  }
 
  if (calc_covar_)
    calctype = "covariance";
  else
    calctype = "correlation";
 
  mprintf("    AUTOCORR: Calculating auto-%s for %i data sets:\n\t", calctype, dsets_.size());
  for (unsigned int idx = 0; idx != dsets_.size(); ++idx)
    mprintf(" %s", dsets_[idx]->legend());
  mprintf("\n");
  if (lagmax_!=-1)
    mprintf("\tLag max= %i\n", lagmax_);
  if ( !setname.empty() )
    mprintf("\tSet name: %s\n", setname.c_str() );
  if ( outfile != 0 )
    mprintf("\tOutfile name: %s\n", outfile->DataFilename().base());
  if (usefft_)
    mprintf("\tUsing FFT to calculate %s.\n", calctype);
  else
    mprintf("\tUsing direct method to calculate %s.\n", calctype);

  return Analysis::OK;
}
开发者ID:SAMAN-64,项目名称:cpptraj,代码行数:63,代码来源:Analysis_AutoCorr.cpp

示例14: Sort_pH_Data

//  Exec_SortEnsembleData::Sort_pH_Data()
int Exec_SortEnsembleData::Sort_pH_Data(DataSetList const& setsToSort, DataSetList& OutputSets,
                                        unsigned int maxFrames)
const
{
  // Cast sets back to DataSet_PHREMD
  typedef std::vector<DataSet_PHREMD*> Parray;
  Parray PHsets;
  for (DataSetList::const_iterator ds = setsToSort.begin(); ds != setsToSort.end(); ++ds)
    PHsets.push_back( (DataSet_PHREMD*)*ds );

  // Gather initial pH data values, ensure no duplicates
  typedef std::vector<double> Darray;
  Darray pHvalues;
# ifdef MPI
  pHvalues.resize( Parallel::Ensemble_Size() );
  Darray phtmp;
  for (Parray::const_iterator ds = PHsets.begin(); ds != PHsets.end(); ++ds)
    phtmp.push_back( (*ds)->Initial_pH() );
  if (comm_.AllGather(&phtmp[0], phtmp.size(), MPI_DOUBLE, &pHvalues[0])) {
    rprinterr("Error: Gathering pH values.\n");
    return 1;
  }
# else
  for (Parray::const_iterator ds = PHsets.begin(); ds != PHsets.end(); ++ds)
    pHvalues.push_back( (*ds)->Initial_pH() );
# endif
  ReplicaInfo::Map<double> pH_map;
  if (pH_map.CreateMap( pHvalues )) {
    rprinterr("Error: Duplicate pH value detected (%.2f) in ensemble.\n", pH_map.Duplicate());
    return 1;
  }
  Darray sortedPH;
  mprintf("\tInitial pH values:");
  for (ReplicaInfo::Map<double>::const_iterator ph = pH_map.begin(); ph != pH_map.end(); ++ph)
  {
    mprintf(" %6.2f", ph->first);
    sortedPH.push_back( ph->first );
  }
  mprintf("\n");

  // Create sets to hold sorted pH values. Create a set for each pH value
  // and each residue. Final output sets will be PH0R0, PH0R1, PH1R0, ...
  // TODO check that residue info all the same
  DataSet_PHREMD::Rarray const& Residues = PHsets[0]->Residues();
  int defaultState = 0;
# ifdef MPI
  if ( PHsets[0]->Type() == DataSet::PH_IMPL)
    defaultState = -1;
# endif
  if (debug_ > 0)
    rprintf("DEBUG: Sorting %u frames for %zu sets, %zu pH values.\n",
            maxFrames, PHsets.size(), sortedPH.size());
  for (unsigned int idx = 0; idx != sortedPH.size(); idx++) {
    OutputSets.SetEnsembleNum( idx );
    for (unsigned int res = 0; res != Residues.size(); ++res) {
      MetaData md(PHsets[0]->Meta().Name(), Residues[res].Name().Truncated(), Residues[res].Num());
      DataSet_pH* out = (DataSet_pH*)OutputSets.AddSet( DataSet::PH, md );
      if (out==0) return 1;
      //out->SetLegend( "pH " + doubleToString( sortedPH[idx] ) );
      out->Set_Solvent_pH( sortedPH[idx] );
      out->SetResidueInfo( Residues[res] );
      out->SetTimeValues(PHsets[0]->Time());
      out->Resize( maxFrames, defaultState );
    }
  }

  // ---------------------------------------------
  if ( PHsets[0]->Type() == DataSet::PH_EXPL) {
    // Loop over unsorted sets
    for (Parray::const_iterator ds = PHsets.begin(); ds != PHsets.end(); ++ds)
    {
      DataSet_PHREMD_Explicit* in = (DataSet_PHREMD_Explicit*)*ds;
      unsigned int phidx = 0;
      for (unsigned int n = 0; n < maxFrames; n++)
      {
        float phval = in->pH_Values()[n];
        int setidx = pH_map.FindIndex( phval ) * Residues.size();
        //rprintf("DEBUG: %6u Set %10s pH= %6.2f going to %2i\n", n+1, in->legend(), phval, idx);
        //mflush();
        for (unsigned int res = 0; res < in->Residues().size(); res++, setidx++, phidx++)
        {
          DataSet_pH* out = (DataSet_pH*)OutputSets[setidx];
          //if (res == 0 && idx == 0) {
          //  rprintf("DEBUG: Frame %3u res %2u State %2i pH %6.2f\n", 
          //          n, res, in->Res(res).State(n), phval);
          //  mflush();
          //}
          out->SetState(n, in->ResStates()[phidx], in->RecordType(n));
        }
      }
    } // END loop over unsorted sets
#   ifdef MPI
    // Now we need to reduce down each set onto the thread where it belongs.
    if (Parallel::World().Size() > 1) {
      for (int idx = 0; idx != (int)OutputSets.size(); idx++) {
        DataSet_pH* out = (DataSet_pH*)OutputSets[idx];
        int ensembleRank = Parallel::MemberEnsCommRank( out->Meta().EnsembleNum() );
        //rprintf("DEBUG: Reduce set %s to rank %i\n", out->legend(), ensembleRank);
        out->Reduce( comm_, ensembleRank );
//.........这里部分代码省略.........
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:101,代码来源:Exec_SortEnsembleData.cpp

示例15: WriteDataNormal

// DataIO_Std::WriteDataNormal()
int DataIO_Std::WriteDataNormal(CpptrajFile& file, DataSetList const& Sets) {
  // Assume all 1D data sets.
  if (Sets.empty() || CheckAllDims(Sets, 1)) return 1;
  // For this output to work the X-dimension of all sets needs to match.
  // The most important things for output are min and step so just check that.
  // Use X dimension of set 0 for all set dimensions.
  CheckXDimension( Sets );
  // TODO: Check for empty dim.
  DataSet* Xdata = Sets[0];
  Dimension const& Xdim = static_cast<Dimension const&>( Xdata->Dim(0) );
  int xcol_width = Xdim.Label().size() + 1; // Only used if hasXcolumn_
  if (xcol_width < 8) xcol_width = 8;
  int xcol_precision = 3;

  // Determine size of largest DataSet.
  size_t maxFrames = DetermineMax( Sets );

  // Set up X column.
  TextFormat x_col_format(XcolFmt());
  if (hasXcolumn_) {
    if (XcolPrecSet()) {
      xcol_width = XcolWidth();
      x_col_format = TextFormat(XcolFmt(), XcolWidth(), XcolPrec());
    } else {
      // Create format string for X column based on dimension in first data set.
      // Adjust X col precision as follows: if the step is set and has a 
      // fractional component set the X col width/precision to either the data
      // width/precision or the current width/precision, whichever is larger. If
      // the set is XYMESH but step has not been set (so we do not know spacing 
      // between X values) use default precision. Otherwise the step has no
      // fractional component so make the precision zero.
      double step_i;
      double step_f = modf( Xdim.Step(), &step_i );
      double min_f  = modf( Xdim.Min(),  &step_i );
      if (Xdim.Step() > 0.0 && (step_f > 0.0 || min_f > 0.0)) {
        xcol_precision = std::max(xcol_precision, Xdata->Format().Precision());
        xcol_width = std::max(xcol_width, Xdata->Format().Width());
      } else if (Xdata->Type() != DataSet::XYMESH)
        xcol_precision = 0;
      x_col_format.SetCoordFormat( maxFrames, Xdim.Min(), Xdim.Step(), xcol_width, xcol_precision );
    }
  } else {
    // If not writing an X-column, no leading space for the first dataset.
    Xdata->SetupFormat().SetFormatAlign( TextFormat::RIGHT );
  }

  // Write header to buffer
  std::vector<int> Original_Column_Widths;
  if (writeHeader_) {
    // If x-column present, write x-label
    if (hasXcolumn_)
      WriteNameToBuffer( file, Xdim.Label(), xcol_width, true );
    // To prevent truncation of DataSet legends, adjust the width of each
    // DataSet if necessary.
    for (DataSetList::const_iterator ds = Sets.begin(); ds != Sets.end(); ++ds) {
      // Record original column widths in case they are changed.
      Original_Column_Widths.push_back( (*ds)->Format().Width() );
      int colLabelSize;
      if (ds == Sets.begin() && !hasXcolumn_)
        colLabelSize = (int)(*ds)->Meta().Legend().size() + 1;
      else
        colLabelSize = (int)(*ds)->Meta().Legend().size();
      //mprintf("DEBUG: Set '%s', fmt width= %i, colWidth= %i, colLabelSize= %i\n",
      //        (*ds)->legend(), (*ds)->Format().Width(), (*ds)->Format().ColumnWidth(),
      //        colLabelSize);
      if (colLabelSize >= (*ds)->Format().ColumnWidth())
        (*ds)->SetupFormat().SetFormatWidth( colLabelSize );
    }
    // Write dataset names to header, left-aligning first set if no X-column
    DataSetList::const_iterator set = Sets.begin();
    if (!hasXcolumn_)
      WriteNameToBuffer( file, (*set)->Meta().Legend(), (*set)->Format().ColumnWidth(), true  );
    else
      WriteNameToBuffer( file, (*set)->Meta().Legend(), (*set)->Format().ColumnWidth(), false );
    ++set;
    for (; set != Sets.end(); ++set) 
      WriteNameToBuffer( file, (*set)->Meta().Legend(), (*set)->Format().ColumnWidth(), false );
    file.Printf("\n"); 
  }

  // Write Data
  DataSet::SizeArray positions(1);
  for (positions[0] = 0; positions[0] < maxFrames; positions[0]++) {
    // Output Frame for each set
    if (hasXcolumn_)
      file.Printf( x_col_format.fmt(), Xdata->Coord(0, positions[0]) );
    for (DataSetList::const_iterator set = Sets.begin(); set != Sets.end(); ++set) 
      (*set)->WriteBuffer(file, positions);
    file.Printf("\n"); 
  }
  // Restore original column widths if necessary
  if (!Original_Column_Widths.empty())
    for (unsigned int i = 0; i != Original_Column_Widths.size(); i++)
      Sets[i]->SetupFormat().SetFormatWidth( Original_Column_Widths[i] );
  return 0;
}
开发者ID:Amber-MD,项目名称:cpptraj,代码行数:97,代码来源:DataIO_Std.cpp


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