//
// Forward_list.hpp
// 练习
//
// Created by hanzhiqiang on 2017/6/11.
// Copyright © 2017年 hanzhiqiang. All rights reserved.
//
#ifndef Forward_list_hpp
#define Forward_list_hpp
#include <stdio.h>
#include <iostream>
#include <forward_list>
using namespace std;
int main()
{
forward_list<string> mList;
mList.emplace_front("aaa");
mList.emplace_front("bbb");
mList.emplace_front("ccc");
for (auto it = mList.begin(); it != mList.end(); it++)
{
cout<<*it<<endl;
}
// for (auto it = mList.before_begin(); it != mList.end(); it++)
// {
// cout<<*it<<endl;
// }
// auto itList = find(mList.begin(), mList.end(), "fff");
// if (itList != mList.end()) \
// {
// mList.emplace_after(itList, "111");
// }
// else
// {
// mList.insert_after(mList.end(),"222");//c++ primer p 313 向末尾插入数据结果未知 error
// }
auto prev = mList.before_begin();
auto curr = mList.begin();
bool isInsert = false;
while (curr != mList.end())
{
if (*curr == "fff")
{
curr = mList.insert_after(curr, "111");
isInsert = true;
}
prev = curr;
curr++;
}
if(!isInsert)
{
curr = mList.insert_after(prev, "222");//向末尾插入数据成功
}
for (auto it = mList.begin(); it != mList.end(); it++)
{
cout<<"插入元素后"<<*it<<endl;
}
cout<<"fuck"<<endl;
return 0;
}
#endif /* Forward_list_hpp */
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有