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


C++ StringVector::erase方法代码示例

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


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

示例1: FindLineCommentMarker

/*!
* Detect the character(s) that is used for marking a line as a comment line.
* If such a character is found, it is added to LineCommentStart vector.
* Since assembly code counter covers multiple assembly languages, there can be
* mulitple markers in the same program. 
* GNU Assembler, for instance, supports # and ; for comment lines
*
* \param fmap list of file lines
*
*/
void CAssemblyCounter::FindLineCommentMarker(filemap* fmap)
{
    StringVector markerChecklist;   // contains line comment markers that need to be checked/tested
    markerChecklist.push_back("#");
    markerChecklist.push_back(";");
    markerChecklist.push_back("|");

    LineCommentStart.clear();       // remove all existing values just in case it was set unintentionally

    /* Algorithm:
        1.	Read each line
            a.	For each comment marker, find position/index of the marker
                i.	If position is 0, a marker is found
                    1.	Save/add the marker: LineCommentStart.push_back()
                    2.	Remove the marker from the check list
                ii.	If position is > 0 && not last index && (position-1) is a space, a marker is found.
                    1.	Save/add the marker: LineCommentStart.push_back()
                    2.	Remove the marker from the check list
    */
    StringVector::iterator nextMarker;
    string line;
    size_t position;
    for (filemap::iterator fit = fmap->begin(); fit != fmap->end(); fit++)
    {
        line = fit->line;
        nextMarker = markerChecklist.begin();
        while (nextMarker != markerChecklist.end())
        {
            position = line.find(*nextMarker);
            if (position == string::npos)
            {
                nextMarker++;
                continue;
            }
            else if (position == 0)
            {
                LineCommentStart.push_back(*nextMarker);
                nextMarker = markerChecklist.erase(nextMarker);
            }
            else if (position > 0 && position != (line.length() - 1) && line.at(position - 1) == ' ')
            {
                LineCommentStart.push_back(*nextMarker);
                nextMarker = markerChecklist.erase(nextMarker);
            }
            else
                nextMarker++;
        }
    }
}
开发者ID:XiangyuLi926,项目名称:2016SummerUCCProject,代码行数:59,代码来源:CAssemblyCounter.cpp

示例2: removeFromMetadataCollection

void Metadata::removeFromMetadataCollection(const string& key, const string& value, TransactionFactory& transactionFactory, TransactionContext& transactionContext)
	{
	auto_ptr<Transaction> transaction = transactionFactory.createTransaction(transactionContext);

	StringVector values = getMetadataCollection(key, *transaction);
	values.erase(remove(values.begin(), values.end(), value), values.end());
	putMetadata(key, values, *transaction);

	transaction->commit();
	}
开发者ID:chravikishore,项目名称:indexeddb,代码行数:10,代码来源:Metadata.cpp

示例3: CleanRadarList

	ERMsg CUIEnvCanRadar::CleanRadarList(StringVector& radarList, CCallback& callback)const
	{
		ERMsg msg;

		callback.PushTask(GetString(IDS_CLEAN_LIST), radarList.size());
		//callback.SetNbStep(radarList.size());

		for (StringVector::iterator it = radarList.begin(); it != radarList.end() && msg;)
		{
			if (FileExists(GetOutputFilePath(as<size_t>(TYPE), *it)))
				it = radarList.erase(it);
			else
				it++;

			msg += callback.StepIt();
		}

		callback.PopTask();

		return msg;
	}
开发者ID:RNCan,项目名称:WeatherBasedSimulationFramework,代码行数:21,代码来源:UIEnvCanRadar.cpp

示例4: removeDuplicate

//remove dedup string in strs-vector
void removeDuplicate(StringVector& strs)
{
	if(1 >= strs.size())
		return;
	StringVector sstrs = strs; //dedup by sort
	std::sort(sstrs.begin(),sstrs.end());
	std::string rstr = ""; //result of temp
	bool isReplicate = false; //flag 
	for(std::size_t i = 0;i < sstrs.size() - 1;++i)
	{
		if(sstrs[i] == sstrs[i+1])
		{
			rstr = sstrs[i];
			isReplicate = true;
		}
		else
		{
			bool isFirst = true;
			for(std::size_t ii = 0;ii< strs.size();++ii)
			{
				if(rstr == strs[i])
				{
					if(isFirst)
					{
						isFirst = false;
					}
					else
					{
						strs.erase(strs.begin() + ii);
						ii--;
					}
				}
			}
			isReplicate = false;
		}
	}
}
开发者ID:syw2014,项目名称:work-projects,代码行数:38,代码来源:StringUtil.cpp

示例5: ProcessPath

bool CConverToMK::ProcessPath(const char* pszVCPath,
							  const char* pszPath,
							  string& strRes )
{
	if (0 == pszPath || !*pszPath)
	{
		return false;
	}

	if (strRes.size())
	{
		strRes = "";
	}

	filesystem::path kVCFile(pszVCPath);
	filesystem::path kMKFile(m_pszMKFile);
	filesystem::path kInputPath(pszPath);

	unsigned int uiParentFolderCount = 0;
	string strFilename = kInputPath.filename().string();

	kInputPath = kInputPath.parent_path();

	kVCFile = kVCFile.parent_path();
	kMKFile = kMKFile.parent_path();

	StringVector kVCSets;
	StringVector kMKSets;
	StringVector kTargetSets;
	StringVector kTempVC;

	BOOST_AUTO(pkInputPathPos,kInputPath.begin());
	BOOST_AUTO(pkVCPos,kVCFile.begin());
	BOOST_AUTO(pkMKPos,kMKFile.begin());

	while (pkInputPathPos != kInputPath.end())
	{
		string strPath = pkInputPathPos->string().c_str();

		if (strcmp(strPath.c_str(),"..") == 0)
		{
			uiParentFolderCount++;
			pkInputPathPos++;
			continue;
		}

		kTargetSets.push_back(strPath);
		pkInputPathPos++;
	}

	while (pkVCPos != kVCFile.end())
	{
		filesystem::path strVC = *pkVCPos;
		kVCSets.push_back(strVC.string());
		pkVCPos++;
	}

	kTempVC = kVCSets;

	while (0 < uiParentFolderCount)
	{
		kTempVC.pop_back();
		kVCSets.pop_back();
		uiParentFolderCount--;
	}

	while (pkMKPos != kMKFile.end())
	{
		string strVC = pkMKPos->string();
		kMKSets.push_back(strVC);
		pkMKPos++;
	}

	unsigned int uiMin = kMKSets.size() < kVCSets.size() ?
		kMKSets.size() : kVCSets.size();
	unsigned int uiIndex = 0;

	for (uiIndex = 0;uiIndex < uiMin;uiIndex++)
	{
		if (strcmp(kMKSets[uiIndex].c_str(),kVCSets[uiIndex].c_str()) != 0)
		{
			break;
		}
	}

	kMKSets.erase(kMKSets.begin(),kMKSets.begin() + uiIndex);
	kVCSets.erase(kVCSets.begin(),kVCSets.begin() + uiIndex);

	strRes += ".";
	string strPrePath = "";

	for (unsigned int uiIndex = 0;uiIndex < kTempVC.size();uiIndex++)
	{
		strPrePath += kTempVC[uiIndex];
		strPrePath += "\\";
	}

	for (unsigned int uiIndex = 0;uiIndex < kVCSets.size();uiIndex++)
	{
		strRes += "\\";
//.........这里部分代码省略.........
开发者ID:jonesgithub,项目名称:HHHH,代码行数:101,代码来源:ConverToMK.cpp


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