当前位置:网站首页>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;
}


边栏推荐
猜你喜欢
随机推荐
[SAM template question] P3975 [TJOI2015] string theory
leetcode:127. Word Solitaire
Android安全性优化——APP加固
BFS题单总结
[0x800706D9] solution appears in Microsoft Store
Apache Doris series: detailed steps for installation and deployment
Shell脚本 if语句
【LeetCode】42. 接雨水 - Go 语言题解
The first level must project independently
360核心安全大脑3.0正式发布,构建政企用户的“能力中枢平台”
PS基础学习(一)
怎么开通代付通道接口?
Reverse linked list - in-place inversion method
H5跳转微信公众号解决方案
2021GDCPC广东省大学生程序设计竞赛 B.Byfibonacci
Android security optimization - APP reinforcement
DFS question list and template summary
MPI简谈
反转链表-就地逆置法
【LeetCode】70. 爬楼梯 - Go 语言题解








