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


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

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: while

forward_list<int> LinkedListsExpert::partition(forward_list<int> list, int x){
    forward_list<int> lessThanX, greaterThanX, equalX;
    forward_list<int>::iterator it = list.begin();
    while (it!=list.end()) {
        if (*it < x) {
            lessThanX.push_front(*it);
        } else if (*it > x){
            greaterThanX.push_front(*it);
        } else{
            equalX.push_front(*it);
        }
        it++;
    }
    //merge lists
    it = equalX.begin();
    while (it != equalX.end()) {
        greaterThanX.push_front(*it);
        it++;
    }
    it = lessThanX.begin();
    while (it != lessThanX.end()) {
        greaterThanX.push_front(*it);
        it++;
    }
    return greaterThanX;
}
开发者ID:HebaWaly,项目名称:ProblemsSolver,代码行数:26,代码来源:LinkedListsExpert.cpp

示例5: listCopy

void listCopy(forward_list<T> L, forward_list<T> &P) // reverse L and put it into P
{
    for(typename forward_list<T>::iterator start = L.begin() ; start != L.end() ; ++start)
    {
        P.push_front(*start);
    }
}
开发者ID:achen067,项目名称:CS14-SPRING2015,代码行数:7,代码来源:lab2.cpp

示例6: 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

示例7: printLots

void printLots(forward_list<T> L, forward_list<int> P)
{
    int num_elem = 0;
    
    for (typename forward_list<T>::iterator count = L.begin() ; count != L.end() ; ++count)
    {
        num_elem = num_elem + 1;
    }
    
    while(!P.empty())
    {
        int pos = P.front();
        
        if(pos >= num_elem)
        {
            cout << "Position out of bounds!" << endl;
            return;
        }
        
        typename forward_list<T>::iterator start = L.begin();
        
        for(int i = 0 ; i < pos ; i++)
        {
            ++start;
        }
        
        cout << *start << ", ";
        
        P.pop_front();
    }
    
    cout << endl;
}
开发者ID:achen067,项目名称:CS14-SPRING2015,代码行数:33,代码来源:lab2.cpp

示例8: printList

void LinkedListsExpert::printList(forward_list<int> list){
    std::forward_list<int>::iterator it;
    for (it = list.begin(); it != list.end(); it++) {
        cout << *it << "  ";
    }
    cout << "\n";
}
开发者ID:HebaWaly,项目名称:ProblemsSolver,代码行数:7,代码来源:LinkedListsExpert.cpp

示例9: printTroopers

	void printTroopers(void) {
		for (atk_pos = attackers_fw_list.begin(); atk_pos != attackers_fw_list.end(); atk_pos++) {
			cout << "Runde:" << atk_pos->getRound() << "   --X:" << atk_pos->getLine() << "--Y:" << atk_pos->getY()
					<< "--Owner:" << atk_pos->getOwner() << "--Range:" << atk_pos->getRange() << "--DMG:"
					<< atk_pos->getRange() << "--HP:" << atk_pos->getHp() << "--Movement:" << atk_pos->getMovement()
					<< endl << endl;
		}
	};
开发者ID:rumfrickelinsky,项目名称:VSY,代码行数:8,代码来源:player_and_board.hpp

示例10: getNthToLast

int LinkedListsExpert::getNthToLast(forward_list<int> list, int n){
    forward_list<int>::iterator current = list.begin();
    forward_list<int>::iterator previous = list.begin();
    
    for(int i=1; i<=n; i++){
        if (current != list.end()) {
            current++;
        }
    }
    
    while (current != list.end()) {
        current++;
        previous++;
    }
    
    return *previous;
}
开发者ID:HebaWaly,项目名称:ProblemsSolver,代码行数:17,代码来源:LinkedListsExpert.cpp

示例11: getInfoAtPosit

TypeInfo getInfoAtPosit(forward_list<TypeInfo> laListe, int laPosition) throw (PrecondVioleeExcep) {
    // version itérative
    // un itérateur sur la liste
    auto it = laListe.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 != laListe.end())) {
        positionCourante++;
        // avancer dans la liste sur l'itérateur
        ++it;
    }
    if (it != laListe.end()) { // si on eu accès à laPosition
        // rendre l'élément pointé par l'itérateur
        return *it;
    } else { // sinon on lève une exception
        throw PrecondVioleeExcep("Accès imposible à l'indice " + to_string(laPosition));
    }
}
开发者ID:Ivan-Roger,项目名称:TP_de_Cpp,代码行数:18,代码来源:premiercontact.cpp

示例12: find_last_kth

T find_last_kth(const forward_list<T>& l, int k)
{
    assert(k>=0);

    auto it = l.begin();
    for (int i=0; i<k; ++i) {
        if (it==l.end()) {
            return l.front();
        }
        ++it;
    }
    auto ret = l.begin();
    while (it!=l.end()) {
        ++it;
        ++ret;
    }
    return *ret;
}
开发者ID:simonracz,项目名称:ccup5,代码行数:18,代码来源:solution_2.2.cpp

示例13: display

void display(forward_list<T> lst)
{
    
    for(typename forward_list<T>::iterator start = lst.begin(); start != lst.end() ; ++start)
    {
        cout << *start << " ";
    }
    
    cout << endl;
}
开发者ID:achen067,项目名称:CS14-SPRING2015,代码行数:10,代码来源:lab2.cpp

示例14: 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

示例15: 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


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