STL-list 链表
#include <iostream>
#include <list> using namespace std; int main()
{
// list可以在头部和尾部插入和删除元素
// 不能随机访问元素,迭代器只能++,不能一次性跳转
list<int> L;
//L.push(1);
L.push_back();
L.push_front();
L.push_back(); for(list<int>::iterator it=L.begin();it!=L.end();++it)
{
// it=L.begin()+1也不行
cout<<*it<<' ';
//it+=1;
//it=it+1;
}
cout<<endl; //删除
//erase
list<int>::iterator it=L.begin();
++it;
L.erase(it); for(list<int>::iterator it=L.begin();it!=L.end();++it)
{
cout<<*it<<' ';
}
cout<<endl; // remove ->值删除
L.remove();
for(list<int>::iterator it=L.begin();it!=L.end();++it)
{
cout<<*it<<' ';
}
cout<<endl;
L.remove();
for(list<int>::iterator it=L.begin();it!=L.end();++it)
{
cout<<*it<<' ';
}
cout<<endl; return ;
}
STL-list 链表的更多相关文章
- STL list链表的用法详解
本文以List容器为例子,介绍了STL的基本内容,从容器到迭代器,再到普通函数,而且例子丰富,通俗易懂.不失为STL的入门文章,新手不容错过! 0 前言 1 定义一个list 2 使用list的成员函 ...
- 02-线性结构3 Reversing Linked List(25 point(s)) 【链表】
02-线性结构3 Reversing Linked List(25 point(s)) Given a constant K and a singly linked list L, you are s ...
- bullet HashMap 内存紧密的哈希表
last modified time:2014-11-9 14:07:00 bullet 是一款开源物理引擎,它提供了碰撞检測.重力模拟等功能,非常多3D游戏.3D设计软件(如3D Mark)使用它作 ...
- clientdataset 做为 单机数据库的 使用 学习
http://blog.csdn.net/waveyang/article/details/34146737 unit Unit3; interface uses Winapi.Windows, Wi ...
- 2021.8.11考试总结[NOIP模拟36]
T1 Dove玩扑克 考场并查集加树状数组加桶期望$65pts$实际$80pts$,考后多开个数组记哪些数出现过,只扫出现过的数就切了.用$set$维护可以把被删没的数去掉,更快. $code:$ 1 ...
- Uva 11988 Broken Keyboard STL+链表
两种方法,直接上代码 STL标准模板库 #include <iostream> #include <list> #include <algorithm> #incl ...
- 使用STL中的list容器实现单链表的操作
#include<iostream> #include<list> #include<algorithm> using namespace std; void Pr ...
- C语言实现简单的单向链表(创建、插入、删除)及等效STL实现代码
实现个算法,懒得手写链表,于是用C++的forward_list,没有next()方法感觉很不好使,比如一个对单向链表的最简单功能要求: input: 1 2 5 3 4 output: 1-> ...
- Codeforces 1131 F. Asya And Kittens-双向链表(模拟或者STL list)+并查集(或者STL list的splice()函数)-对不起,我太菜了。。。 (Codeforces Round #541 (Div. 2))
F. Asya And Kittens time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- STL 中的链表排序
一直以来学习排序算法, 都没有在链表排序上下太多功夫,因为用得不多.最近看STL源码,才发现,原来即使是链表,也能有时间复杂度为O(nlogn)的算法, 大大出乎我的意料之外,一般就能想到个插入排序. ...
随机推荐
- python函数中的参数类型
python函数中的参数 动态获取函数的参数 python的函数类型详解
- CCF_201612-3_炉石传说
http://115.28.138.223/view.page?gpid=T45 模拟. #include<iostream> #include<cstring> #inclu ...
- LeetCode 218. The Skyline Problem 天际线问题(C++/Java)
题目: A city's skyline is the outer contour of the silhouette formed by all the buildings in that city ...
- ASP.NET Core使用环境变量
前言 通常在应用程序开发到正式上线,在这个过程中我们会分为多个阶段,通常会有 开发.测试.以及正式环境等.每个环境的参数配置我们会使用不同的参数,因此呢,在ASP.NET Core中就提供了相关的环境 ...
- FTP - File Transfer Protocol
FTP - File Transfer Protocol FTP 实际上使用了两个 TCP 链接. 一个作为控制信道用, 主要传输一些指令和响应, 比如 ACK 或 错误码. 另一个链接是数据信道, ...
- Solr搜索解析及查询解析器用法概述
一.简介 大多数查询都使用 了标准的Solr语法.这种语法是Solr最常见的,由默认查询解析器负责处理.Solr的默认查询解析器是Lucene查询解析器[LuceneQParserPlugin类实现] ...
- Nginx 十大优化 与 防盗链
Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”,是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器.Ngin ...
- 关于OFFICE 文件在线编辑dsoframer
下载dsoframer.ocx 系统为32位时:拷贝 dsoframer.ocx 到c:\windows\system32\dsoframer.ocx打开cmd命令行注册 regsvr32.exe ...
- dotnetcore3.1 WPF 中使用依赖注入
dotnetcore3.1 WPF 中使用依赖注入 Intro 在 ASP.NET Core 中默认就已经集成了依赖注入,最近把 DbTool 迁移到了 WPF dotnetcore 3.1, 在 W ...
- 07.JS对象-2
前言: 学习一门编程语言的基本步骤(01)了解背景知识(02)搭建开发环境(03)语法规范(04)常量和变量(05)数据类型(06)数据类型转换(07)运算符(08)逻辑结构(09)函数(10)对象1 ...