STL的vector略解
2024-10-06 13:21:55
本文部分内容参考于这儿。
vector
的基础知识,上文已经阐述地很详尽了。笔者谨给出 vector
的声明及其常用函数。
- 代码抬头需包含
#include<vector>
using namespace std;
- 定义一个存储
int
类型的vector
类型c
vector<int> c;
- 常用的
vector
函数如下表
vector<int> c;
语句 | 意义 |
---|---|
c.push_back(a) |
将 a 压入 c 的末尾 |
c.pop_back() |
弹出 c 的末尾元素 |
c.pop() |
弹出 c 的首个元素 |
c.size() |
返回 c 的长度 |
c.empty() |
判断 c 是否为空 |
c.clear() |
清空 c |
c.erase(pos) |
移除 pos 处的元素 |
c.erase(begin,end) |
移除 [begin,end) 的元素 |
最新文章
- MFC-01-Chapter01:Hello,MFC---1.1 Windows 编程模型
- Django 创建APP简单步骤
- VC++ 判断文件或文件夹是否存在的快捷方法 _access
- Idea_编译报错 javacTask: 源发行版 1.6 需要目标发行版 1.6
- 第二章 Background &; Borders 之 Multiple borders
- Virtual member call in a constructor
- Implementing Remote Validation in MVC
- Gilde加载网络图片(一)
- 10.30 afternoon
- centos 下使用sublime
- 表单界面的兼容PC手机端解决方案
- Centos7搭建Confluence破解版
- UNIX网络编程——进程间通信概述
- 点击a标签实现txt文件另存的效果
- 统计每日单量MySQL语句
- Mysql SQL优化系列之——执行计划连接方式浅释
- 【LibreOJ】#6395. 「THUPC2018」城市地铁规划 / City 背包DP+Prufer序
- git detached
- 1、Python快速入门(0529)
- 【POJ】4007.Flood-it!
热门文章
- python函数练习
- Ubuntu16.4安装Vivado Design Suite sdx2019.1
- Java第二次作业第一题
- NestedInteger Java
- [Leetcode][动态规划] 零钱兑换
- 关于瀑布流的布局原理分析(纯CSS瀑布流与JS瀑布流)
- 在vue中使用[provide/inject]实现页面reload
- 【SQL server初级】SQL Server 2005 实现数据库同步备份 过程--结果---分析
- POJ 2386——Lake Counting(DFS)
- python爬虫——简易天气爬取