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


C++ multiset::count方法代码示例

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


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

示例1: catagoryGrader

unsigned LyricsMatchGrader::catagoryGrader(const std::multiset<std::string>& lyrics,
										   const std::string& queryWord) const
{
	unsigned int grade = DEFAULT_GRADE;
	size_t wordOccourences = lyrics.count(queryWord);

	if(QUERY_WORD_NOT_FOUND_FLAG != lyrics.count(queryWord))
	{
		grade = (this->getGradingCatagoryWeight()) * (wordOccourences);
	}

	return grade;
}
开发者ID:YafimK,项目名称:SongGrader-UNI-,代码行数:13,代码来源:LyricsMatchGrader.cpp

示例2: checkLetBinding

void Tptp::checkLetBinding(const std::vector<Expr>& bvlist, Expr lhs, Expr rhs,
                           bool formula) {
  if (lhs.getKind() != CVC4::kind::APPLY_UF) {
    parseError("malformed let: LHS must be a flat function application");
  }
  const std::multiset<CVC4::Expr> vars{lhs.begin(), lhs.end()};
  if(formula && !lhs.getType().isBoolean()) {
    parseError("malformed let: LHS must be formula");
  }
  for (const CVC4::Expr& var : vars) {
    if (var.hasOperator()) {
      parseError("malformed let: LHS must be flat, illegal child: " +
                 var.toString());
    }
  }

  // ensure all let-bound variables appear on the LHS, and appear only once
  for (const Expr& bound_var : bvlist) {
    const size_t count = vars.count(bound_var);
    if (count == 0) {
      parseError(
          "malformed let: LHS must make use of all quantified variables, "
          "missing `" +
          bound_var.toString() + "'");
    } else if (count >= 2) {
      parseError("malformed let: LHS cannot use same bound variable twice: " +
                 bound_var.toString());
    }
  }
}
开发者ID:dddejan,项目名称:CVC4,代码行数:30,代码来源:tptp.cpp

示例3: total_receipt

double Basket::total_receipt(ostream &os) const
{
    double sum = 0.0;
    for (auto iter = items.cbegin();
              iter != items.cend();
              iter = items.upper_bound(*iter)) {
        sum += print_total(os, **iter, items.count(*iter));
    }
    os << "Total Sale: " << sum << endl;
    return sum;
}
开发者ID:zpiao1,项目名称:CPP-Primer,代码行数:11,代码来源:Exercise+15.30.cpp

示例4: cancel

		virtual bool cancel(int key)
		{
#ifdef DEBUG
			std::clog << "cancel" << std::endl;
#endif
			bool ret = false;
			pthread_mutex_lock(&cntLock);
			if (boardingPass.count(key))
				ret = true, boardingPass.erase(boardingPass.find(key));
			preserveCnt--;
			pthread_mutex_unlock(&cntLock);
			return ret;
		}
开发者ID:roastduck,项目名称:YAUJ,代码行数:13,代码来源:daemon.cpp

示例5: total

double Basket::total() const
{
    double sum = 0.0;

    for(const_iter i = items.begin() ;  i != items.end() ; i = items.upper_bound(*i))
    {
        sum += (*i)->net_price(items.count(*i));
    }


    return sum;

}
开发者ID:QiJunHu,项目名称:learningRecord,代码行数:13,代码来源:learningHandleClass.cpp

示例6: unique

inline void converter<point_t>::knot_insertion(
    point_container_t& P,
    std::multiset<typename point_t::value_type>& knots,
    std::size_t order) const {
  //typedef typename point_t::value_type value_type;
  std::set<value_type> unique(knots.begin(), knots.end());

  for (typename std::set<value_type>::const_iterator i = unique.begin();
       i != unique.end();
       ++i) {
    if (knots.count(*i) < order - 1) {
      knot_insertion(P, knots, order, *i);
    }
  }
}
开发者ID:4og,项目名称:guacamole,代码行数:15,代码来源:converter_impl.hpp

示例7: decompileRange

void Decompiler::decompileRange(Byte *start, Byte *end) {
  // First, scan for IFFUPJMP, which is used for repeat/until, so
  // we can recognize the start of such loops.  We only keep the
  // last value to match each address, which represents the outermost
  // repeat/until loop starting at that point.
  std::map<Byte *, Byte *> rev_iffupjmp_map;

  for (Byte *scan = start; end == NULL || scan < end;
       scan += get_instr_len(*scan)) {
    if (*scan == IFFUPJMP)
      rev_iffupjmp_map[scan + 2 - scan[1]] = scan;
    else if (*scan == IFFUPJMPW)
      rev_iffupjmp_map[scan + 3 - (scan[1] | (scan[2] << 8))] = scan;
    else if (*scan == ENDCODE)
      break;
  }

  while (end == NULL || start < end) {
    int locs_here = local_var_defs->count(start);
    if (locs_here > 0) {
      // There were local variable slots just pushed onto the stack
      // Print them out (in the second pass)

      // First, if there are multiple defined, it must be from
      // local x, y, z = f() or local a, b.  So just ignore the extra
      // entries.
      for (int i = 1; i < locs_here; i++) {
	delete stk->top(); stk->pop();
      }
      Expression *def = stk->top(); stk->pop();

      // Print the local variable names, and at the same time push
      // fake values onto the stack
      *os << indent_str << "local ";
      for (int i = 0; i < locs_here; i++) {
	std::string locname = localname(tf, tf->code[1] + stk->size());
	*os << locname;
	if (i + 1 < locs_here)
	  *os << ", ";
	stk->push(new VarExpr(start, "<" + locname + " stack slot>"));
      }

      // Print the definition, unless it's nil
      VarExpr *v = dynamic_cast<VarExpr *>(def);
      if (v == NULL || v->name != "nil")
	*os << " = " << *def;
      *os << std::endl;
	  delete def;

      local_var_defs->erase(start);
    }

    if (rev_iffupjmp_map.find(start) != rev_iffupjmp_map.end()) {
      // aha, do a repeat/until loop
      *os << indent_str << "repeat\n";
      Decompiler indented_dc = *this;
      indented_dc.indent_str += std::string(4, ' ');
      indented_dc.break_pos = rev_iffupjmp_map[start];
      indented_dc.break_pos += get_instr_len(*indented_dc.break_pos);
      indented_dc.decompileRange(start, rev_iffupjmp_map[start]);

      Expression *e = stk->top(); stk->pop();
      *os << indent_str << "until " << *e << std::endl;
      delete e;

      start = indented_dc.break_pos;
      continue;
    }

    Byte opc = *start++;
    int aux;

    switch (opc) {
    case ENDCODE:
      return;

    case PUSHNIL:
      aux = *start++;
      goto pushnil;

    case PUSHNIL0:
      aux = 0;
    pushnil:
      for (int i = 0; i <= aux; i++)
	stk->push(new VarExpr(start, "nil")); // Cheat a little :)
      break;

    case PUSHNUMBER:
      aux = *start++;
      goto pushnumber;

    case PUSHNUMBER0:
    case PUSHNUMBER1:
    case PUSHNUMBER2:
      aux = opc - PUSHNUMBER0;
      goto pushnumber;

    case PUSHNUMBERW:
      aux = start[0] | (start[1] << 8);
      start += 2;
//.........这里部分代码省略.........
开发者ID:Botje,项目名称:residualvm-tools,代码行数:101,代码来源:delua.cpp

示例8: run

		virtual Json::Value run(int key, int pid, int sid, const Json::Value &submission)
		{
#ifdef DEBUG
			std::clog << "run" << std::endl;
			std::clog << " pid=" << pid << " sid=" << sid << " key=" << key << std::endl;
#endif
			pthread_mutex_lock(&cntLock);
			if (!boardingPass.count(key))
			{
				pthread_mutex_unlock(&cntLock);
				Json::Value ret;
				ret["error"] = "not preserved";
				return ret;
			}
			boardingPass.erase(boardingPass.find(key));
			runningCnt++, totCnt++;
			const int _totCnt_ = totCnt;
			pthread_mutex_unlock(&cntLock);
			
			Json::Value ret;
			std::ostringstream ss;
			ss << runPath << "/" << _totCnt_;
			std::string runDir = ss.str();
			pthread_mutex_lock(&cmdLock);
#ifdef DEBUG
			std::clog << "mkdir -p "+runDir << std::endl;
#endif
			system(("mkdir -p "+runDir).c_str());
#ifdef DEBUG
			std::clog << "rm -r "+runDir+"/*" << std::endl;
#endif
			system(("rm -r "+runDir+"/*").c_str());
			pthread_mutex_unlock(&cmdLock);
			try
			{
				ss.str("");
				ss << "cp " + dataPath + "/" << pid << "/* " << runDir;
				pthread_mutex_lock(&syncLock);
				if (syncing.count(pid)) pthread_mutex_unlock(&syncLock), throw std::string("data updated when copying files.");
#ifdef DEBUG
				std::clog << ss.str() << std::endl;
#endif
				pthread_mutex_lock(&cmdLock), system(ss.str().c_str()), pthread_mutex_unlock(&cmdLock);
				pthread_mutex_unlock(&syncLock);
				ss.str("");
				ss << "cp " + sourcePath + "/" << sid/10000 << '/' << sid%10000 << "/* " << runDir;
#ifdef DEBUG
				std::clog << ss.str() << std::endl;
#endif
				pthread_mutex_lock(&cmdLock), system((ss.str()).c_str()), pthread_mutex_unlock(&cmdLock);
				ss.str("");
				ss << "./yauj_judge run";
				for (Json::Value::const_iterator i=submission.begin(); i!=submission.end(); i++)
					ss << " " << (*i)["language"].asString() << " " << (*i)["source"].asString();
				ret=dumpCmd(ss.str(),runDir);
#ifndef NCLEAN
				pthread_mutex_lock(&cmdLock), system(("rm -r "+runDir).c_str()), pthread_mutex_unlock(&cmdLock);
#endif
			} catch (std::string &e)
			{
#ifdef DEBUG
				std::clog << " run: catched " << e << std::endl;
#endif
				pthread_mutex_lock(&cntLock);
				runningCnt--, preserveCnt--;
				pthread_mutex_unlock(&cntLock);
				ret["error"] = e;
				return ret;
			}
			pthread_mutex_lock(&cntLock);
			runningCnt--, preserveCnt--;
			pthread_mutex_unlock(&cntLock);
			return ret;
		}
开发者ID:roastduck,项目名称:YAUJ,代码行数:74,代码来源:daemon.cpp

示例9: Qw

inline void converter<point_t>::knot_insertion(point_container_t& P,
                                               std::multiset<value_type>& knots,
                                               std::size_t order,
                                               value_type t) const {
  typedef typename point_t::value_type value_type;

  // copy knotvector for subscript [] access
  std::vector<value_type> kv_cpy(knots.begin(), knots.end());
  // get parameter
  std::size_t p = order - 1;                        // degree
  std::size_t s = knots.count(t);                   // multiplicity
  std::size_t r = std::max(std::size_t(0), p - s);  // number of insertions

  // get knotspan
  std::size_t k = std::distance(knots.begin(), knots.upper_bound(t));
  std::size_t np = P.size();  // number of control points

  // start computation
  std::size_t nq = np + r;

  // helper arrays
  std::vector<point_t> Qw(nq);
  std::vector<point_t> Rw(p - s + 1);

  // copy unaffected points and transform into homogenous coords
  for (size_t i = 0; i <= k - p; ++i) {
    Qw[i] = P[i].as_homogenous();
  }
  for (size_t i = k - s - 1; i <= np - 1; ++i) {
    Qw[i + r] = P[i].as_homogenous();
  }

  // helper points
  for (size_t i = 0; i <= p - s; ++i) {
    Rw[i] = P[k - p + i - 1].as_homogenous();
  }

  // do knot insertion itself
  std::size_t L = 0;
  for (std::size_t j = 1; j <= r; ++j) {
    L = k - p + j;
    for (std::size_t i = 0; i <= p - j - s; ++i) {
      value_type alpha =
          (t - kv_cpy[L + i - 1]) / (kv_cpy[i + k] - kv_cpy[L + i - 1]);
      Rw[i] = alpha * Rw[i + 1] + value_type(1.0 - alpha) * Rw[i];
    }
    Qw[L - 1] = Rw[0];
    Qw[k + r - j - s - 1] = Rw[p - j - s];
  }

  // insert knots
  for (std::size_t i = 0; i < r; ++i) {
    knots.insert(t);
  }

  // copy new control points
  P.clear();

  // transform back to euclidian space
  for (typename std::vector<point_t>::iterator i = Qw.begin(); i != Qw.end();
       ++i) {
    P.push_back((*i).as_euclidian());
  }
}
开发者ID:4og,项目名称:guacamole,代码行数:64,代码来源:converter_impl.hpp


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