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


C++ map::cend方法代码示例

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


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

示例1: GetRecordByFields

int Database::GetRecordByFields(const string tableName, map<string, string> fieldValues, vector< map<string, string> >* out, string sortField, bool bAsc) const
{
	if (!Util::IsLetterNumberDash(tableName) || !Util::IsLetterNumberDash(sortField))
		return 2;

	string order = " ORDER BY " + sortField + (bAsc ? " ASC;" : " DSC;");
	string sql = "SELECT * FROM " + tableName + " WHERE ";

	auto it = fieldValues.cbegin();
	while (it != fieldValues.cend())
	{
		if (!Util::IsLetterNumberDash((*it).first))
			return 2;
		sql.append(Util::ToUpper((*it).first + "='"));
		//*TODO: Check value
		sql.append((*it).second + "'");

		++it;
		if (it != fieldValues.cend())
			sql.append(" AND ");
	}

	sql += order;

	return Exec(sql, out);
}
开发者ID:tianlang0704,项目名称:UO2016WCIS422AddressBook,代码行数:26,代码来源:Database.cpp

示例2: map_intersection

void map_intersection(map<Key, Value>& lhs, map<Key, Value> const& rhs)
{
    typedef typename map<Key, Value>::iterator input_iterator1;
    typedef typename map<Key, Value>::const_iterator input_iterator2;

    input_iterator1 it1 = lhs.begin();
    input_iterator2 it2 = rhs.cbegin();
    input_iterator1 end1 = lhs.end();
    input_iterator2 end2 = rhs.cend();
    while (it1 != end1 && it2 != end2) {
        if (it1->first == it2->first) {
            it1->second += it2->second;
            ++it1;
            ++it2;
        }
        else {
            if (it1->first < it2->first) {
                ++it1;
            }
            else {
                ++it2;
            }
        }
    }
}
开发者ID:caomw,项目名称:k_means_tree,代码行数:25,代码来源:k_means_tree.hpp

示例3: while

void grouped_vocabulary_tree<Point, K>::merge_maps(map<int, int>& map1, const map<int, int>& map2)
{
    using iter = map<int, int>::iterator;
    using citer = map<int, int>::const_iterator;

    iter it1 = map1.begin();
    citer it2 = map2.cbegin();
    iter end1 = map1.end();
    citer end2 = map2.cend();
    while (it2 != end2) {
        bool done1 = it1 == end1;
        if (!done1 && it1->first == it2->first) { // element already in 1, just increase count
            it1->second += it2->second;
            ++it1;
            ++it2;
        }
        else {
            if (done1 || it1->first > it2->first) {
                // from c++11 docs:
                // The function optimizes its insertion time if position points to the element
                // that will follow the inserted element (or to the end, if it would be the last).
                map1.insert(it1, *it2);
                ++it2;
            }
            else {
                ++it1; // if map1 is large while map2 is small this will not give better than const time insertion
            }
        }
    }
}
开发者ID:caomw,项目名称:k_means_tree,代码行数:30,代码来源:grouped_vocabulary_tree.hpp

示例4:

void EulerUtils::Display::printMap ( string itemName, const map<string, int>& data ) {
	cout << "in printMap" << endl;
	cout << "Printing " << itemName << "..." << endl;
	for ( auto i = data.cbegin(); i != data.cend(); i++ )
        cout << i->first << ": " << i->second << endl;
    cout << endl;
}
开发者ID:terentz,项目名称:EulerProjectCPP,代码行数:7,代码来源:EulerUtils.cpp

示例5: string_to_colour

/*! \brief          Convert the name of a colour to a colour
    \param  str     name of a colour
    \return         the colour corresponding to <i>str</i>
*/
const int string_to_colour(const string& str)
{ static const map<string, int> colour_map { { "BLACK",   COLOUR_BLACK },
                                             { "BLUE",    COLOUR_BLUE },
                                             { "CYAN",    COLOUR_CYAN },
                                             { "GREEN",   COLOUR_GREEN },
                                             { "MAGENTA", COLOUR_MAGENTA },
                                             { "RED",     COLOUR_RED },
                                             { "WHITE",   COLOUR_WHITE },
                                             { "YELLOW",  COLOUR_YELLOW }
                                           };

  const string s = to_upper(remove_peripheral_spaces(str));
  const auto cit = colour_map.find(s);

  if (cit != colour_map.cend())
    return cit->second;

// should change this so it works with a colour name and not just a number
  if (begins_with(s, "COLOUR_"))
    return (from_string<int>(substring(s, 7)));

  if (begins_with(s, "COLOR_"))
    return (from_string<int>(substring(s, 6)));

  if (s.find_first_not_of(DIGITS) == string::npos)  // if all digits
    return from_string<int>(s);

  return COLOUR_BLACK;    // default
}
开发者ID:N7DR,项目名称:drlog,代码行数:33,代码来源:screen.cpp

示例6: toString

string Story::toString (const map<int, string> &glossary) const
{
	string result = "";
	result += this->timeStamp;
	for (const int wordID : this->words)
		if (glossary.find (wordID) != glossary.cend ())
			result += " " + glossary.find (wordID)->second;
	return result;
}
开发者ID:xavierwu,项目名称:TopicDetectionAndTracking,代码行数:9,代码来源:Story.cpp

示例7: AddRecord

int Database::AddRecord(const string tableName, const map<string, string> newEntry)
{
	if (!Util::IsLetterNumberDash(tableName))
		return 2;

	string sql = "INSERT INTO " + tableName + " (";
	
	auto it = newEntry.cbegin();
	while(it != newEntry.cend())
	{
		if (!Util::IsLetterNumberDash((*it).first))
			return 2;

		if (Util::ToUpper((*it).first).compare("ID") == 0)
		{
			++it;
			continue;
		}

		sql.append(Util::ToUpper((*it).first));

		++it;
		if (it != newEntry.cend())
			sql.append(",");
		else
			sql.append(") ");
	}

	sql.append("VALUES(");
	it = newEntry.cbegin();
	while (it != newEntry.cend())
	{
		//*TODO: Check values
		sql.append("'" + (*it).second + "'");

		++it;
		if (it != newEntry.cend())
			sql.append(",");
		else
			sql.append(");");
	}

	return Exec(sql);
}
开发者ID:tianlang0704,项目名称:UO2016WCIS422AddressBook,代码行数:44,代码来源:Database.cpp

示例8: getOrCreateId

 Id getOrCreateId(const Name& u) {
   auto u_it = names.find(u);
   if( u_it != names.cend() )
     return u_it->second;
   else {
     Id u_id = (unsigned) nodes.size();
     nodes.push_back(Node(u));
     names.insert(make_pair(u, u_id));
     return u_id;
   }
 }
开发者ID:hurryabit,项目名称:codeeval.com,代码行数:11,代码来源:WhichWayIsFaster.cpp

示例9:

// --------------------------------------------------------------------------
inline
std::string
provider::realm () const
// --------------------------------------------------------------------------
{
  map::const_iterator it = m_req.find("realm");

  if (it != m_req.cend())
  {
    return it->second;
  }

  return "";
}
开发者ID:fumu-no-kagomeko,项目名称:libkueea-openid-auth,代码行数:15,代码来源:provider.hpp

示例10: AddFeasCat

void Model::AddFeasCat(map<string, int> feaofcat, string catname,int threshold)
{
	auto itfc = feaofcat.cbegin();
	int count = 1;
	while (itfc != feaofcat.cend())
	{
		if (itfc->second <= threshold)
		{
			++itfc;
			continue;
		}
		stringstream query;
		query<< "insert into fc (feature,cat,count) values ('" << itfc->first << "','" << catname << "'," << itfc->second << ")";
		this->ExecuteSQL(query.str().c_str());
		++itfc;
	}
}
开发者ID:chenyahui,项目名称:Text-Classification,代码行数:17,代码来源:Model.cpp

示例11: showMap

std::string RelationManager::showMap(const map<const Class *, set<const Class *> > &map, std::string msg) const
{
	std::string s;

	if (map.empty()) return "";

	if (msg != "")
		s.append(msg + "\n");
	for (auto i = map.cbegin(); i != map.cend(); i++) {
		s.append(i->first->getName() + ": ");
		for (auto j = i->second.cbegin(); j != i->second.cend(); j++)
			s.append((*j)->getName() + " ");
		s.append("\n");
	}

	return s.append("\n");
}
开发者ID:termNinja,项目名称:rs16-24,代码行数:17,代码来源:relationmanager.cpp

示例12: getOpValue

double getOpValue(const string &token){
	//cout<<"GetOpValue="<<token<<endl;
	switch(checkOpType(token)){
		case pure_number:
			return stod(token);
		case identifier:
			{
				auto it=variable.find(token);
				if(it==variable.cend()){
					variable[token]=0.0;
					return 0.0;
				}else
					return it->second;
			}
		case syntax_error:;
	}
}
开发者ID:tim37021,项目名称:calculator,代码行数:17,代码来源:main.cpp

示例13: evaluate

	bool evaluate(const Point& inputPos, const Direction* inputDir, Point& outputPos, const Direction*& outputDir) const
	{
		if (inputDir == nullptr)
		{
			return false;
		}
		FlowConstIterator it = flows_.find(inputDir);
		if (it != flows_.cend())
		{
			outputDir = &(it->second->opposite());
			outputPos = inputPos + *it->second;
			return true;
		}
		else
		{
			return false;
		}
	}
开发者ID:laurbrid,项目名称:codingame,代码行数:18,代码来源:indiana.cpp

示例14: setTFIDFBasedOnCorpus

/* Set 'tfidf', based on corpus */
void Story::setTFIDFBasedOnCorpus (const vector<Story> &corpus,
								   const map<int, set<int>> &storiesIndexWithCertainWord)
{
	if (this->termFrequency.empty ())
		this->setTermFrequency ();

	this->tfidf = this->termFrequency;
	for (map<int, double>::iterator iter = this->tfidf.begin ();
		 iter != this->tfidf.end (); ++iter) {
		if (storiesIndexWithCertainWord.find (iter->first) != storiesIndexWithCertainWord.cend ()) {
			double idf = 0.0;
			double storiesWithWord = 0.0;
			storiesWithWord = storiesIndexWithCertainWord.find (iter->first)->second.size ();
			idf = log (corpus.size () / storiesWithWord);
			iter->second *= idf;
		}
	}
}
开发者ID:xavierwu,项目名称:TopicDetectionAndTracking,代码行数:19,代码来源:Story.cpp

示例15: compatibleVM

bool compatibleVM(solution antSol,int i,ll n,int j,Server s,map<ll,qualifiedVM> omega)
{
    ll remCPU=s.ThreshCPU,remMEM=s.ThreshMEM;
	if(antSol.array[i]==-1 && (omega.find((ll)i)==omega.cend()))
	{
		for(register int k=0;k<n;k++)
		{
			if(antSol.array[k]!=-1 && antSol.array[k]==j)
			{
				remCPU-=(vm[k].CPU);
				remMEM-=(vm[k].MEM);
			}
		}
		if(remCPU>vm[i].CPU && remMEM>vm[i].MEM)
		{
			return true;
		}
		else return false;
	}
	return false;
}
开发者ID:amanmokama,项目名称:Ant-Colony-Optimization,代码行数:21,代码来源:CodeScrap.cpp


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