c plus STL and vector

本文详细介绍了STL(标准模板库),它是C++标准库的重要组成部分,包括容器、迭代器、分配器、适配器、算法和仿函数六大组件。重点讲解了向量(Vector)这一容器的特点、构造方法及成员函数。

STL(Standard Template Library)

STL is a c plus software library that influenced many parts of the C++ Standard Library.It provides four components, which called algorithms, containers, functors, and iterators. Such as HP STL、PJ STL、 SGI STL etc.

STL has been built within your complier.And it has many different versions.http://write.blog.youkuaiyun.com/postedit

In ANSI C ++ STL is organized into 13 header files:<algorithm>, <deque>, <functional><iterator>, <vector>, <list>, <map>, <memory>, <numeric>, <queue>, <set>, <stack>, <utility>.

And STL can be devided into 6 parts, including containers, iterators, allocators, adaptors, algorithms, functors.


Vector

Vector is considered a container, because of it can storge variable types objects just like containers.it can be used as a dynamic array . In order to use vector, we should include the header file <vector>. And the vector is contained in the std namesapce,so if we intend to use the vector, we also need to limit the namespace as follows:

usingnamespace std;

Of course,for using vector, there are some advantages but also some disadvantages.It can work fast for random access..., while slowly for insertion and deletion...


Constructors:

vector();

vector(int initialcapacity, int capacityIncrement);

vector(int initialcapacity);

For the first constructor, operator will manage the vector automatically.but for the latter two constructors, vector will be initialized with the fixed capacity. and when the capacity is not enough to store the data, the vector' capasity will be increased with the size of  capacityincrement.


define:

vector<type> vector_name;

member functions:

assign(beg, end);

assign the data of the region between beg and end to c.


assgin(n, elem);

assigin n datas to c.


at(idx);

return the data of index idx,if cross the border, throw an exception :out_of_range.


back();

return the last data without check if the data exist.


begin();

return the firt address of the iterator.


capacity();

return the number of the datas that be stored in capacity.


clear();

remove all datas from the capacity.


empty();

check if the capacity is empty.


end();

refer to the next of the last data, which is not exist.


erase(pos);

delete the data at position pos,and return the address of the next data.


erase(beg, end);

delete datas of the region between beg and end, and return the address of the next data.


front();

return the first data.


get_allocator();

use the copy constructor and return a copy.


insert(pos, elem);

insert an element at the position pos, and return the address of the new data.


insert(pos, n, elem);

insert n datas at the position, and without return value.


max_size();

return the number of the maximum datas.


pop_back();

delete the last data.


push_back(elem);

insert an element to the end of the datas.


rbegin();

return the first data of an reverse queue.


rend();

refer to the next address of the last data in an reverse queue.


resize(num);

resize the length of the queue.


reserve();

reserve some capacitys.


size();

return the number of the datas in capacity.


【四轴飞行器】非线性三自由度四轴飞行器模拟器研究(Matlab代码实现)内容概要:本文围绕非线性三自由度四轴飞行器的建模与仿真展开,重点介绍了基于Matlab的飞行器动力学模型构建与控制系统设计方法。通过对四轴飞行器非线性运动方程的推导,建立其在三维空间中的姿态与位置动态模型,并采用数值仿真手段实现飞行器在复杂环境下的行为模拟。文中详细阐述了系统状态方程的构建、控制输入设计以及仿真参数设置,并结合具体代码实现展示了如何对飞行器进行稳定控制与轨迹跟踪。此外,文章还提到了多种优化与控制策略的应用背景,如模型预测控制、PID控制等,突出了Matlab工具在无人机系统仿真中的强大功能。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的高校学生、科研人员及从事无人机系统开发的工程师;尤其适合从事飞行器建模、控制算法研究及相关领域研究的专业人士。; 使用场景及目标:①用于四轴飞行器非线性动力学建模的教学与科研实践;②为无人机控制系统设计(如姿态控制、轨迹跟踪)提供仿真验证平台;③支持高级控制算法(如MPC、LQR、PID)的研究与对比分析; 阅读建议:建议读者结合文中提到的Matlab代码与仿真模型,动手实践飞行器建模与控制流程,重点关注动力学方程的实现与控制器参数调优,同时可拓展至多自由度或复杂环境下的飞行仿真研究。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值