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


C++ forward_list::before_begin方法代码示例

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


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

示例1: insertString

void insertString(forward_list<string> &strflst, const string &search, const string &str)
{
	auto prev = strflst.before_begin();
	auto curr = strflst.begin();
	if (!strflst.empty())
	{
		bool flag = false;
		while(curr != strflst.end())
		{
			if (*curr == search)
			{
				curr = strflst.insert_after(curr, str);
				flag = true;
			}
			else
			{
				prev = curr++;
			}
		}
		if (!flag)
		{
			strflst.insert_after(prev, str);
		}
	}
}
开发者ID:cschengshuo,项目名称:CppPrimer,代码行数:25,代码来源:ex9_28.cpp

示例2: insertAfterStr

void insertAfterStr(forward_list<string> &flist, string flag, string insert){
	auto pre = flist.before_begin();
	auto item = flist.begin();
	while (item != flist.end() && *item != flag)
		pre++, item++;
	item == flist.end() ? flist.insert_after(pre, insert) : flist.insert_after(item, insert);
}
开发者ID:Leelddd,项目名称:CppPrimer_5th,代码行数:7,代码来源:ex_28.cpp

示例3: updateSounds

void updateSounds() {
	auto prevIt = sounds.before_begin();
	for (auto it = sounds.begin(); it != sounds.end(); it++) {
		if (it->getStatus() == sf::Sound::Stopped) {
			sounds.erase_after(prevIt);
			it = prevIt;
		}
		else prevIt = it;
	}
}
开发者ID:payload,项目名称:gorge,代码行数:10,代码来源:helper.cpp

示例4: remove_evens_and_double_odds

void remove_evens_and_double_odds(forward_list<int>& data) {
    for (auto cur = data.begin(), prev = data.before_begin(); cur != data.end(); ) {
        if (*cur & 0x1)
            cur = data.insert_after(prev, *cur),
            advance(prev, 2),
            advance(cur, 2);
        else
            cur = data.erase_after(prev);
    }
}
开发者ID:RanchoCooper,项目名称:Cpp-Primer,代码行数:10,代码来源:ex09_31_2.cpp

示例5: insertWord

void insertWord(forward_list<string> &forList,
                                           const string &str1,const string &str2)
{
    auto prev = forList.before_begin();
    for(auto i=forList.begin();i != forList.end();prev=i,++i)
        if(*i == str1){
            forList.insert_after(i,str2);
            return ;
        }
   forList.insert_after(prev,str2);
}
开发者ID:devilchew,项目名称:Exercise,代码行数:11,代码来源:练习9-28.cpp

示例6: func

forward_list<string> func(forward_list<string> &il, string s1, string s2) {
    auto iter = il.begin();
    auto prev = il.before_begin();
    for (; iter != il.end(); prev = iter++)
        if (*iter == s1)
            break;
    if (iter == il.end())
        il.insert_after(prev, s2);
    else
        il.insert_after(iter, s2);
    return il;
}
开发者ID:qinf,项目名称:cpp_primer,代码行数:12,代码来源:9.28.cpp

示例7: insertString

void insertString(forward_list<string>& fls,string target,string insertval){
	auto cur=fls.begin();
	auto prev=fls.before_begin();
	while(cur!=fls.end()&&*cur!=target) {
	   prev=cur;
	   ++cur;
	}
	if(cur!=fls.end())
		fls.insert_after(cur,insertval);
	else{
		fls.insert_after(prev,insertval);
	}
}
开发者ID:gaufung,项目名称:CppPrimer,代码行数:13,代码来源:Ex9_28.cpp

示例8: find_and_insert

void find_and_insert(forward_list<string> &list, string const& to_find, string const& to_add)
{
    auto prev = list.before_begin();
    for (auto curr = list.begin(); curr != list.end(); prev = curr++)
    {
        if (*curr == to_find)
        {
            list.insert_after(curr, to_add);
            return;
        }
    }
    list.insert_after(prev, to_add);
}
开发者ID:jimingye,项目名称:Cpp-practice,代码行数:13,代码来源:9_28.cpp

示例9: func

void func(forward_list<string> &flist, const string s1, const string s2)
{
	auto before = flist.before_begin();
	auto curr = flist.begin();
	while(curr!=flist.end()) {
		if(*curr == s1){
			flist.insert_after(curr, s2);
			return;
		}else{
			curr++;
		}
	}
	flist.insert_after(curr, s2);
}
开发者ID:goodyang,项目名称:forlearn,代码行数:14,代码来源:exercise9.28.cpp

示例10: insereInfoAtPosit

void insereInfoAtPosit(forward_list<T1>& maListeOriginale, int laPosition, T2 nouvelleInfo) throw (PrecondVioleeExcep) {
    // version itérative
    // itérateur positionné sur la postion avant le premier élément de la liste
    //  -> il faut être sur le précédent de laPosition pour fair l'insertion après !!
    auto it = maListeOriginale.before_begin();
    int positionCourante = 1;
    // tantque l'on a pas atteint laPosition et que l'on est pas à la fin de la liste
    while ((positionCourante < laPosition) && (it != maListeOriginale.end())) {
        positionCourante++;
        // avancer dans la liste sur l'itérateur
        ++it;
    }
    if (it != maListeOriginale.end()) { // si on a accès à laPosition
        // insérer après l'élément pointé par l'itérateur
        it = maListeOriginale.insert_after(it, nouvelleInfo);
    } else { // sinon on lève une exception
        throw PrecondVioleeExcep("Insertion imposible à l'indice " + to_string(laPosition));
    }
}
开发者ID:Ivan-Roger,项目名称:TP_de_Cpp,代码行数:19,代码来源:premiercontact.cpp

示例11: replace

void replace(forward_list<string> &sflst, const string &str1, const string &str2)
{
        int     flag = 0;
        auto    prev = sflst.before_begin();
        auto    curr = sflst.begin();
        auto    end = sflst.end();
        while (curr != end)
                if (*curr == str1)
                {
                        curr = sflst.emplace_after(curr, str2);
                        flag = 1;
                }
                else
                {
                        prev = curr;
                        ++curr;
                }
        if (!flag)
                sflst.insert_after(prev, str2);
}
开发者ID:autyinjing,项目名称:Cpp-learning,代码行数:20,代码来源:9.28.cpp

示例12: FindStringInsertString

void FindStringInsertString(forward_list<string>& strlist, string strtofind, string strtoinsert)
{
	forward_list<string>::iterator current = strlist.begin();
	forward_list<string>::iterator pre = strlist.before_begin();
	bool findflag = false;
	while (current != strlist.end())
	{
		if (*current == strtofind)
		{
			current = strlist.insert_after(current,strtoinsert);
			findflag = true;
		}
		pre = current;
		current++;
	}
	
	if (!findflag)
	{
		strlist.insert_after(pre, strtoinsert);
	}
	return;
}
开发者ID:tangbin90,项目名称:Learning-Cplusplus,代码行数:22,代码来源:BlockDropping.cpp


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