当前位置:网站首页>45. [Application of list linked list]
45. [Application of list linked list]
2022-07-30 23:34:00 【Lee is struggling...】
[Insert a data in the header]
Function name.push_front()
[Insert a data at the end]
Function name.push_back()
【Multiple Insertion Data】
Function name.insert(function name.begin(),n) Where to start and who to insert
[Multiple Insertion Data 2]
Function name.insert(function name.begin(),n,m) Where to start, how many to insert, who to insert
[Insert using iterator]
iist
Object name=function name.begin();
Function name.insert(object name, number, element)
[Delete the first element]
Function name.pop_front()
[Remove last element]
Function name.pop_back()
【Multiple delete data】
function name 1.erase(function name 1.begin(), function name 1.end()
[Linked list traversal can only be iterator traversal]
iist
for(object name=function name.begin();object name!=end();object name++)
{
cout<<*object name;
}
#include
#include
using namespace std;
int main()
{
list
int s[4] = { 2,5,8 };
list
list_b.push_front(1); //Insert at the head
list_b.push_back(2); //Insert at the end
list_b.insert(list_b.begin(), 66); // where to insert, what to insert
list_b.insert(list_b.end(), 88);
list_b.insert(list_b.end(),3, 100); // where to insert, how many to insert, who to insert
list
it = list_b.begin();
it++;
list_b.insert(it, 5, 111);
list_b.insert(list_b.begin(), s, s + sizeof(s) / sizeof(int)); //insert a normal array
list_b.pop_front(); //delete the first one
list_b.pop_back(); //delete the last one
//list_b.erase(list_b.begin(), list_b.end()); // delete from the beginning
list
for (itor = list_b.begin(); itor!= list_b.end(); itor++)
{
cout << *itor << " ";
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Unity 加载读取PPT
uniapp develops WeChat applet - soft exam brushing applet
【LeetCode】64. 最小路径和 - Go 语言题解
IJCAI2022 Tutorial | Spoken Language Comprehension: Recent Advances and New Fields
动态修改el-tab-pane 的label(整理)
“蔚来杯“2022牛客暑期多校训练营4 L.Black Hole 垃圾计算几何
PS基础学习(一)
10 个关于自动化发布管理的好处
数据清洗-使用es的ingest
flutter 做底部的三个按键,有叠加,有填充
47.【指针与数组】
Shell脚本 if语句
Data cleaning - ingest using es
2022 Nioke Summer Multi-School Training Camp 1 J Serval and Essay
机器学习1一回归模型(二)
会员生日提前了一天
[动态规划] 0-1背包问题和完全背包问题
软考学习计划
proemthues 服务发现配置
Apache Doris series: In-depth understanding of real-time analytical database Apache Doris