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


C++ TStr::Len方法代码示例

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


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

示例1: PrintReport

void TTmProfiler::PrintReport(const TStr& ProfileNm) const {
    const double TimerSumSec = GetTimerSumSec();
	printf("-- %s --\n", ProfileNm.CStr());
    printf("Sum: (%.2f sec):\n", TimerSumSec);
    int TimerId = GetTimerIdFFirst();
	while (GetTimerIdFNext(TimerId)) {
        // get timer name
        TStr TimerNm = GetTimerNm(TimerId);
        TimerNm = TStr::GetSpaceStr(TInt::GetMx(0, TimerNm.Len() - MxNmLen)) + TimerNm;
        // get timer time and precentage
        if (TimerSumSec > 0.0) {
            const double TimerSec = GetTimerSec(TimerId);
            const double TimerPerc =  TimerSec / TimerSumSec * 100.0;
            printf(" %s: %.2fs [%.2f%%]\n", TimerNm.CStr(), TimerSec, TimerPerc);
        } else {
            printf(" %s: -\n", TimerNm.CStr());
        }
    }
	printf("--\n");
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:20,代码来源:tm.cpp

示例2: LoadFunFileV

//////////////////////////////////////
// File-Download-Function
void TSASFunFile::LoadFunFileV(const TStr& FPath, TSAppSrvFunV& SrvFunV) {
	TFFile File(FPath, "", false); TStr FNm;
	while (File.Next(FNm)) {
		TStr FExt = FNm.GetFExt();
		TStr FUrl = FNm.GetSubStr(FPath.Len());
		FUrl.ChangeChAll('\\', '/');
		printf("%s %s %s\n", FNm.CStr(), FExt.CStr(), FUrl.CStr());
		if (FExt == ".htm") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::TextHtmlFldVal)); }
		else if (FExt == ".html") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::TextHtmlFldVal)); }
		else if (FExt == ".js") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::TextJavaScriptFldVal)); }
		else if (FExt == ".css") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::TextCssFldVal)); }
		else if (FExt == ".jpg") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::ImageJpgFldVal)); }
		else if (FExt == ".jpeg") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::ImageJpgFldVal)); }
		else if (FExt == ".gif") { SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::ImageGifFldVal)); }
		else {
			printf("Unknown MIME type for extension '%s' for file '%s'", FExt.CStr(), FNm.CStr());
			SrvFunV.Add(TSASFunFile::New(FUrl, FNm, THttp::AppOctetFldVal)); 
		}
	}	
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:22,代码来源:sappsrv.cpp

示例3: BetaM

/////////////////////////////////////////////////
// 2 populations SIR model
TSir2Model::TSir2Model(double _N0M, TFltTr N0MP, double _I0M, TFltTr I0MP, double _N0B, TFltTr N0BP, double _I0B, TFltTr I0BP, 
  int _T0, TFltTr T0P, double _BetaM, TFltTr BetaMP, double _GammaM, TFltTr GammaMP, double _BetaB, TFltTr BetaBP, double _GammaB, TFltTr GammaBP, 
  double _BetaMB, TFltTr BetaMBP, double _BetaBM, TFltTr BetaBMP, TStr InFNm, int ColId1, int ColId2) : N0M(_N0M), I0M(_I0M), N0B(_N0B), I0B(_I0B), T0(_T0), BetaM(_BetaM), 
  GammaM(_GammaM), BetaB(_BetaB), GammaB(_GammaB), BetaMB(_BetaMB), BetaBM(_BetaBM) { 
  ParamMnMnRngV.Add(N0MP);
  ParamMnMnRngV.Add(I0MP);
  ParamMnMnRngV.Add(N0BP);
  ParamMnMnRngV.Add(I0BP);
  ParamMnMnRngV.Add(T0P);
  ParamMnMnRngV.Add(BetaMP);
  ParamMnMnRngV.Add(GammaMP);
  ParamMnMnRngV.Add(BetaBP);
  ParamMnMnRngV.Add(GammaBP);
  ParamMnMnRngV.Add(BetaMBP);
  ParamMnMnRngV.Add(BetaBMP);
  if (InFNm.Len()>0 && TFile::Exists(InFNm)) {
    TEpidemModel::LoadTxt(InFNm, ColId1, MediaV); 
    TEpidemModel::LoadTxt(InFNm, ColId2, BlogV); 
  }
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:22,代码来源:sir.cpp

示例4: GetTmFromWebLogTimeStr

TTm TTm::GetTmFromWebLogTimeStr(const TStr& TimeStr,
 const char TimeSepCh, const char MSecSepCh){
  int TimeStrLen=TimeStr.Len();
  // year
  TChA ChA; int ChN=0;
  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
    ChA+=TimeStr[ChN]; ChN++;}
  TStr HourStr=ChA;
  // minute
  ChA.Clr(); ChN++;
  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
    ChA+=TimeStr[ChN]; ChN++;}
  TStr MinStr=ChA;
  // second
  ChA.Clr(); ChN++;
  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=MSecSepCh)){
    ChA+=TimeStr[ChN]; ChN++;}
  TStr SecStr=ChA;
  // mili-second
  ChA.Clr(); ChN++;
  while (ChN<TimeStrLen){
    ChA+=TimeStr[ChN]; ChN++;}
  TStr MSecStr=ChA;
  if (MSecStr.Len() > 3) {
	  MSecStr = MSecStr.GetSubStr(0, 2); 
  } else if (MSecStr.Len() == 1) {
	  MSecStr += "00";
  } else if (MSecStr.Len() == 2) {
	  MSecStr += "0";
  }
  // transform to numbers
  int HourN=HourStr.GetInt(0);
  int MinN=MinStr.GetInt(0);
  int SecN=SecStr.GetInt(0);
  int MSecN=MSecStr.GetInt(0);
  // construct time
  TTm Tm(-1, -1, -1, -1, HourN, MinN, SecN, MSecN);
  // return time
  return Tm;
}
开发者ID:Bradeskojest,项目名称:qminer,代码行数:40,代码来源:tm.cpp

示例5: AddVNm

/////////////////////////////////////////////////
// Cyc-Base
int TCycBs::AddVNm(const TStr& VNm){
  int VId;
  if (VNmToVrtxH.IsKey(VNm.CStr(), VId)){
    return VId;
  } else {
    VId=VNmToVrtxH.AddKey(VNm);
    TCycVrtx& Vrtx=VNmToVrtxH[VId];
    Vrtx.PutVId(VId);
    // set flags based on vertex-name string
    if (VNm.IsPrefix("~")){
      Vrtx.SetFlag(cvfBackLink);
    } else
    if (VNm.IsPrefix("#$")&&(!VNm.IsChIn(' '))){
      Vrtx.SetFlag(cvfCycL);
      if (VNm.Len()>2){
        char Ch=VNm[2];
        if (('a'<=Ch)&&(Ch<='z')){
          Vrtx.SetFlag(cvfCycLPred);
        } else {
          Vrtx.SetFlag(cvfCycLConst);
        }
      }
    } else
    if (VNm.IsPrefix("(#$")){
      Vrtx.SetFlag(cvfCycL);
      Vrtx.SetFlag(cvfCycLExpr);
    } else {
      if (VNm.IsFlt()){
        Vrtx.SetFlag(cvfNum);
      } else {
        Vrtx.SetFlag(cvfStr);
      }
    }
    return VId;
  }
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:38,代码来源:cyc.cpp

示例6: TSBase

TMIn::TMIn(const TStr& Str):
  TSBase("Input-Memory"), TSIn("Input-Memory"), Bf(NULL), BfC(0), BfL(0){
  BfL=Str.Len(); Bf=new char[BfL]; strncpy(Bf, Str.CStr(), BfL);
}
开发者ID:andrejmuhic,项目名称:qminer,代码行数:4,代码来源:fl.cpp

示例7: Send

void TWebFetchSendBatchJson::Send() {
  TStr BodyStr = TJsonVal::GetStrFromVal(JsonArray);
  TMem BodyMem; BodyMem.AddBf(BodyStr.CStr(), BodyStr.Len());
  PHttpRq HttpRq = THttpRq::New(hrmPost, TUrl::New(UrlStr), THttp::AppJSonFldVal, BodyMem);
  FetchHttpRq(HttpRq);
}
开发者ID:Zala,项目名称:qminer,代码行数:6,代码来源:webpgfetch.cpp

示例8: SetLcCh

void THttpChDef::SetLcCh(const TStr& Str){
  for (int ChN=1; ChN<Str.Len(); ChN++){LcChV[Str[ChN]-TCh::Mn]=TCh(Str[0]);}}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:2,代码来源:http.cpp

示例9: AddFtr

void TBagOfWords::AddFtr(const TStr& Val, TIntFltKdV& SpV) const {
    // tokenize
    TStrV TokenStrV(Val.Len() / 5, 0); GetFtr(Val, TokenStrV);
    // create sparse vector
    AddFtr(TokenStrV, SpV);
}
开发者ID:joaopitacosta,项目名称:qminer,代码行数:6,代码来源:ftrgen.cpp

示例10: Put

void TSysConsole::Put(const TStr& Str){
  DWORD ChsWritten;
  WriteConsole(hStdOut, Str.CStr(), Str.Len(), &ChsWritten, NULL);
  IAssert(ChsWritten==DWORD(Str.Len()));
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:5,代码来源:os.cpp

示例11: SetChTy

void TLxChDef::SetChTy(const TLxChTy& ChTy, const TStr& Str){
  for (int CC=0; CC<Str.Len(); CC++){
    ChTyV[Str[CC]-TCh::Mn]=TInt(ChTy);}
}
开发者ID:tadejs,项目名称:qminer-1,代码行数:4,代码来源:lx.cpp

示例12: GetArgPostfix

TStr TEnv::GetArgPostfix(const TStr& PrefixStr) const {
    int ArgN = GetPrefixArgN(PrefixStr);
    IAssert(ArgN != -1);
    TStr ArgStr = GetArg(ArgN);
    return ArgStr.GetSubStr(PrefixStr.Len(), ArgStr.Len());
}
开发者ID:zzjjzzgggg,项目名称:netsnap,代码行数:6,代码来源:env.cpp

示例13: RunMCMC

/// MCMC fitting
void TAGMFit::RunMCMC(const int& MaxIter, const int& EvalLambdaIter, const TStr& PlotFPrx) {
  TExeTm IterTm, TotalTm;
  double PrevL = Likelihood(), DeltaL = 0;
  double BestL = PrevL;
  printf("initial likelihood = %f\n",PrevL);
  TIntFltPrV IterTrueLV, IterJoinV, IterLeaveV, IterAcceptV, IterSwitchV, IterLBV;
  TIntPrV IterTotMemV;
  TIntV IterV;
  TFltV BestLV;
  TVec<TIntSet> BestCmtySetV;
  int SwitchCnt = 0, LeaveCnt = 0, JoinCnt = 0, AcceptCnt = 0, ProbBinSz;
  int Nodes = G->GetNodes(), Edges = G->GetEdges();
  TExeTm PlotTm;
  ProbBinSz = TMath::Mx(1000, G->GetNodes() / 10); //bin to compute probabilities
  IterLBV.Add(TIntFltPr(1, BestL));

  for (int iter = 0; iter < MaxIter; iter++) {
    IterTm.Tick();
    int NID = -1;
    int JoinCID = -1, LeaveCID = -1;
    SampleTransition(NID, JoinCID, LeaveCID, DeltaL); //sample a move
    double OptL = PrevL;
    if (DeltaL > 0 || Rnd.GetUniDev() < exp(DeltaL)) { //if it is accepted
      IterTm.Tick();
      if (LeaveCID > -1 && LeaveCID != BaseCID) { LeaveCom(NID, LeaveCID); }
      if (JoinCID > -1 && JoinCID != BaseCID) { JoinCom(NID, JoinCID); }
      if (LeaveCID > -1 && JoinCID > -1 && JoinCID != BaseCID && LeaveCID != BaseCID) { SwitchCnt++; }
      else if (LeaveCID > -1  && LeaveCID != BaseCID) { LeaveCnt++;}
      else if (JoinCID > -1 && JoinCID != BaseCID) { JoinCnt++;}
      AcceptCnt++;
      if ((iter + 1) % EvalLambdaIter == 0) {
        IterTm.Tick();
        MLEGradAscentGivenCAG(0.01, 3);
        OptL = Likelihood();
      }
      else{
        OptL = PrevL + DeltaL;
      }
      if (BestL <= OptL && CIDNSetV.Len() > 0) {
        BestCmtySetV = CIDNSetV;
        BestLV = LambdaV;
        BestL = OptL;
      }
    }
    if (iter > 0 && (iter % ProbBinSz == 0) && PlotFPrx.Len() > 0) { 
      IterLBV.Add(TIntFltPr(iter, OptL));
      IterSwitchV.Add(TIntFltPr(iter, (double) SwitchCnt / (double) AcceptCnt));
      IterLeaveV.Add(TIntFltPr(iter, (double) LeaveCnt / (double) AcceptCnt));
      IterJoinV.Add(TIntFltPr(iter, (double) JoinCnt / (double) AcceptCnt));
      IterAcceptV.Add(TIntFltPr(iter, (double) AcceptCnt / (double) ProbBinSz));
      SwitchCnt = JoinCnt = LeaveCnt = AcceptCnt = 0;
    }
    PrevL = OptL;
    if ((iter + 1) % 10000 == 0) {
      printf("\r%d iterations completed [%.2f]", iter, (double) iter / (double) MaxIter);
    }
  }
  
  // plot the likelihood and acceptance probabilities if the plot file name is given
  if (PlotFPrx.Len() > 0) {
    TGnuPlot GP1;
    GP1.AddPlot(IterLBV, gpwLinesPoints, "likelihood");
    GP1.SetDataPlotFNm(PlotFPrx + ".likelihood.tab", PlotFPrx + ".likelihood.plt");
    TStr TitleStr = TStr::Fmt(" N:%d E:%d", Nodes, Edges);
    GP1.SetTitle(PlotFPrx + ".likelihood" + TitleStr);
    GP1.SavePng(PlotFPrx + ".likelihood.png");

    TGnuPlot GP2;
    GP2.AddPlot(IterSwitchV, gpwLinesPoints, "Switch");
    GP2.AddPlot(IterLeaveV, gpwLinesPoints, "Leave");
    GP2.AddPlot(IterJoinV, gpwLinesPoints, "Join");
    GP2.AddPlot(IterAcceptV, gpwLinesPoints, "Accept");
    GP2.SetTitle(PlotFPrx + ".transition");
    GP2.SetDataPlotFNm(PlotFPrx + "transition_prob.tab", PlotFPrx + "transition_prob.plt");
    GP2.SavePng(PlotFPrx + "transition_prob.png");
  }
  CIDNSetV = BestCmtySetV;
  LambdaV = BestLV;

  InitNodeData();
  MLEGradAscentGivenCAG(0.001, 100);
  printf("\nMCMC completed (best likelihood: %.2f) [%s]\n", BestL, TotalTm.GetTmStr());
}
开发者ID:RoyZhengGao,项目名称:CommunityEvaluation,代码行数:84,代码来源:agmfit.cpp

示例14: AddTimer

/////////////////////////////////////////////////
// Time-Profiler - poor-man's profiler
int TTmProfiler::AddTimer(const TStr& TimerNm) { 
	MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
	return TimerH.AddKey(TimerNm); 
}
开发者ID:jethrotan,项目名称:qminer,代码行数:6,代码来源:tm.cpp

示例15: LoadTxt

// load from allactors.zip that was prepared by Brad Malin in 2005
PImdbNet TImdbNet::LoadTxt(const TStr& ActorFNm) {
  PImdbNet Net = TImdbNet::New();
  TStrV ColV;
  char line [2024];
  int NLines=0, DupEdge=0, Year, Position, ActorNId, MovieNId;
  TIntH ActorNIdH;
  THash<TIntPr, TInt> MovieNIdH;
  FILE *F = fopen(ActorFNm.CStr(), "rt");  fgets(line, 2024, F);
  while (! feof(F)) {
    memset(line, 0, 2024);
    fgets(line, 2024, F);
    if (strlen(line) == 0) break;
    TStr(line).SplitOnAllCh('|', ColV, false);  IAssert(ColV.Len() == 7);
    const int NameStrId = Net->AddStr(ColV[0].GetTrunc().GetLc()+" "+ColV[1].GetTrunc().GetLc());
    const int MovieStrId = Net->AddStr(ColV[2].GetTrunc().GetLc());
    TStr YearStr = ColV[3].GetTrunc();
    if (YearStr.Len() > 4) YearStr = YearStr.GetSubStr(0, 3);
    Year = 1;  YearStr.IsInt(Year);
    const TMovieTy MovieTy = TImdbNet::GetMovieTy(ColV[4]);
    Position = TInt::Mx;  ColV[5].GetTrunc().IsInt(Position);
    IAssert(ColV[6].GetTrunc()[0] == 'M' || ColV[6].GetTrunc()[0]=='F');
    const bool IsMale = ColV[6].GetTrunc()[0] == 'M';
    // create nodes  
    if (ActorNIdH.IsKey(NameStrId)) { 
      ActorNId = ActorNIdH.GetDat(NameStrId); }
    else { 
      ActorNId = Net->AddNode(-1, TImdbNode(NameStrId, Year, Position, IsMale));
      ActorNIdH.AddDat(NameStrId, ActorNId);
    }
    if (MovieNIdH.IsKey(TIntPr(MovieStrId, Year))) {
      MovieNId = MovieNIdH.GetDat(TIntPr(MovieStrId, Year)); }
    else {
      MovieNId = Net->AddNode(-1, TImdbNode(NameStrId, Year, MovieTy)); 
      MovieNIdH.AddDat(TIntPr(MovieStrId, Year), MovieNId); 
    }
    if (! Net->IsEdge(ActorNId, MovieNId)) { 
      Net->AddEdge(ActorNId, MovieNId); }
    else { DupEdge++; }
    if (++NLines % 100000 == 0) printf("\r  %dk  ", NLines/1000);
  }
  fclose(F);
  printf("duplicate edges: %d\n", DupEdge);
  printf("nodes:  %d\n", Net->GetNodes());
  printf("edges:  %d\n", Net->GetEdges());
  printf("actors: %d\n", ActorNIdH.Len());
  printf("movies: %d\n", MovieNIdH.Len());
  // set the actor year to the year of his first movie
  int NUpdates=0;
  for (TNet::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) {
    if (NI().IsActor()) {
      int MinYear = NI().GetYear();
      for (int e = 0; e < NI.GetOutDeg(); e++) {
        const TImdbNode& NodeDat = Net->GetNDat(NI.GetOutNId(e));
        if (NodeDat.IsMovie()) MinYear = TMath::Mn(MinYear, NodeDat.GetYear());
      }
      if (NI().Year != MinYear) NUpdates++;
      NI().Year = MinYear;
    }
  }
  printf("updated actor times: %d\n", NUpdates);
  return Net;
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:63,代码来源:imdbnet.cpp


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