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


C++ vec::back方法代码示例

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


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

示例1: fixWhileLabels

void fixWhileLabels(){
	int label1=labelStack.back();
	labelStack.pop_back();
	int label2=labelStack.back();
	labelStack.pop_back();
	labelStack.push_back(label1);
	labelStack.push_back(label2);
	
	if(DEBUG)printf("Zamieniam etykiety %d i %d\n", label1, label2);
	
	for(int i=0; i<2; i++){
		int jumperLine=jumpStack.back();
		if(DEBUG)printf("Skok z %d -> ", jumperLine);
		str jumper=tempCode.at(jumperLine);
		
		if(labelStack.size()==0){
			if(DEBUG)printf("NO LABELS LEFT\n");
			return;
		}
		jumpStack.pop_back();
		
		int labelLine=labelStack.back();
		labelStack.pop_back();
		
		char op[10];
		char direction[50];
		char lab[50];
		sscanf(jumper.c_str(), "%s", op);
		if(DEBUG)printf(" ---> %d\n", labelLine+1);
		sprintf(lab, "%s %d", op, labelLine+1);
		str t=lab;
		tempCode.at(jumperLine)=t;	
	}
}
开发者ID:rybycy,项目名称:JfttCompiler,代码行数:34,代码来源:translate.c

示例2: verase

  void verase () {
    if (!pw.size ())
      return;
    char &c = pw.back ();
    if (echo) {
      if (u_char (c) < ' ' || c == '\177')
	output ("\010 \010\010 \010");
      else
	output ("\010 \010");
    }
    c = '\0';
    pw.pop_back ();
  }
开发者ID:Sidnicious,项目名称:sfslite,代码行数:13,代码来源:getkbdnoise.C

示例3: while

static bool
path2vec (vec<str> &out, str in)
{
  const char *p = in.cstr ();
  const char *e = p + in.len ();
  const char *n;

  if (*p != '/')
    return false;
  for (;;) {
    while (*p == '/')
      p++;
    for (n = p; n < e && *n != '/'; n++)
      ;
    if (n == p)
      return true;
    out.push_back (str (p, n - p));
    if (out.back () == "." || out.back () == "..")
      return false;
    p = n;
  }
}
开发者ID:bougyman,项目名称:sfs,代码行数:22,代码来源:safechdir.C

示例4: popAssignedLockedStackByK

void popAssignedLockedStackByK(
    vec<stackEle<valtype, indtype> > &T, signed char **B,
    WV<valtype, indtype> **info, indtype Nagent,
    indtype *residualBudget, indtype K)
{
  for(stackEle<valtype, indtype> *x = &T.back(),
      *xend = x - K; x > xend; --x)
  {
    B[x->task][x->agent] = -1;
    residualBudget[x->agent] += info[x->task][x->agent].weight;
    B[x->task][Nagent] = 0;
  }
  T.resize(T.size() - K);
}
开发者ID:cran,项目名称:FLSSS,代码行数:14,代码来源:DPgapMultithreadKPs.cpp

示例5: backtrack

bool backtrack(vec<stackEle<valtype, indtype> > &T, signed char **B,
               indtype Nagent, WV<valtype, indtype> **info,
               indtype *residualBudget)
{
  while(T.size() > 0 and B[T.back().task][T.back().agent] == 0)
  {
    B[T.back().task][T.back().agent] = -1;
    T.pop_back();
  }
  if(T.size() == 0) return false;
  indtype t = T.back().task, a = T.back().agent;
  B[t][a] = 0;
  B[t][Nagent] = 0;
  residualBudget[a] += info[t][a].weight;
  return true;
}
开发者ID:cran,项目名称:FLSSS,代码行数:16,代码来源:DPgapMultithreadKPs.cpp

示例6: pushAllBranchingVariableIntoStack

void pushAllBranchingVariableIntoStack(
    vec<stackEle<valtype, indtype> > &T,
    signed char **B, indtype Nagent,
    vec<indtype> &overloaded, vec<vec<indtype> > &stay,
    vec<vec<indtype> > &targetTask,
    vec<vec<indtype> > &weight, // overloaded agent, task weights
    vec<vec<valtype> > &penalty, // overloaded agent, task values
    indtype *residualBudget, WV<valtype, indtype> **info)
{
  // Push all elements in stay into stack.
  stackEle<valtype, indtype> *Tst = &*T.end();
  for(indtype i = 0, iend = overloaded.size(); i < iend; ++i)
  {
    indtype a = overloaded[i];
    for(indtype k = 0, kend = stay[i].size(); k < kend; ++k)
    {
      indtype tmp = stay[i][k];
      valtype desirability = penalty[a][tmp] / weight[a][tmp] * residualBudget[a];
      indtype tmpTask = targetTask[a][tmp];
      T.push_back(stackEle<valtype, indtype> (a, tmpTask, desirability));
      if(greedyBranch)
      {
        residualBudget[a] -= weight[a][tmp];
        B[tmpTask][a] = 2;
        B[tmpTask][Nagent] = 1;
      }
      for(stackEle<valtype, indtype> *t = &T.back() - 1; t >= Tst; --t)
      {
        if(t->desirability >= (t + 1)->desirability) break;
        std::swap(t[0], t[1]);
      }
    }
  }


  if(greedyBranch) return;


  // Check if all newly pushed elements in T are appropriate, and if not, pop.
  // This check step is not necessary, but the branch tree may be shaped better.
  {
    indtype a = Tst->agent, t = Tst->task;
    residualBudget[a] -= info[t][a].weight;
    B[t][a] = 2;
    B[t][Nagent] = 1;
  }
  indtype i = 1;
  for(indtype iend = &*T.end() - Tst; i < iend; ++i)
  {
    indtype a = Tst[i].agent, t = Tst[i].task;
    valtype tmpResidualBudget = residualBudget[a] - info[t][a].weight;
    indtype *w = &weight[a][0];
    indtype *ts = &targetTask[a][0];
    bool stackStop = false;
    for(indtype j = 0, jend = weight[a].size(); j < jend; ++j)
    {
      if(ts[j] == t or w[j] <= tmpResidualBudget) continue;
      stackStop = true;
      break;
    }
    if(stackStop) break;
    residualBudget[a] = tmpResidualBudget;
    B[t][a] = 2;
    B[t][Nagent] = 1;
  }
  T.resize(Tst - &*T.begin() + i);
  /*
  Rcout << "stack increased by = " << T.size() - (Tst - &*T.begin()) << "\n";
  Rcout << "After stack push:\n";
  for(indtype t = 1, tend = T.size(); t < tend; ++t)
  {
    Rcout << T[t].agent << ", " << T[t].task << ", " << int(B[T[t].task][T[t].agent]) << ",     ";
  }
  Rcout << "\n";
  */
}
开发者ID:cran,项目名称:FLSSS,代码行数:76,代码来源:DPgapMultithreadKPs.cpp


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