STL容器之Set,MultiSet

本文详细介绍了Set与MultiSet这两种关联容器的特点与使用方法,包括它们的创建、元素插入删除、迭代器操作等,并探讨了这些容器如何自动排序及其背后的二叉树实现原理。
Set,MultiSet都是关联容器,它们的元素是按照一定的顺序排列的并且排列是自动的。关联容器代表性的是用二叉树实现。每一个元素有一个父亲和两个孩子。并且父元素比它的左孩子 要大,比它的右孩子要小。
Set:所有元素不能是重复的。并且按照一定的顺序排列,默认是从小到大。
MultiSet:和Set差不多,只不多它支持重复的元素。

它们的元素自动排序,默认是<。元素间的比较是很严格的:
1.它们是对称的:This means for a predicate op(): If op(x,y) is true, then op(y,x) is false
2.它们是传递的:This means for a predicate op(): If op(x,y) is true and op (y,z) is true, then op(x,z) is true.
3.它们不得是反射的:This means for a predicate op(): op(x,x) is always false.
它们的特点:
1.       它们不支持直接访问元素
2.       间接访问通过Const的迭代器,从迭代器角度来看,它的值是Const的。
Create, Copy, and Destroy Operations
set c                                    Creates an empty set/multiset without any elements
set c(op)                             Creates an empty set/multiset that uses op as the sorting criterion
set c1(c2)                            Creates a copy of another set/multiset of the same type (all elements arecopied)
set c(beg,end)                    Creates a set/multiset initialized by the elements of the range [beg,end)
set c(beg,end,op)               Creates a set/multiset with the sorting criterion op initialized by the elements of the range [beg,end)
c.~set() Destroys all elements and frees the memory
comparisons Operator
c.size() Returns the actual number of elements
c.empty () Returns whether the container is empty (equivalent to size()==0, but might be faster)
c.max_size() Returns the maximum number of elements possible
c1 == c2 Returns whether c1 is equal to c2
c1 != c2 Returns whether c1 is not equal to c2 (equivalent to ! (c1==c2) )
c1 < c2 Returns whether c1 is less than c2
c1 > c2 Returns whether c1 is greater than c2 (equivalent to c2<c1)
c1 <= c2 Returns whether c1 is less than or equal to c2 (equivalent to ! (c2<c1) )
c1 >= c2 Returns whether c1 is greater than or equal to c2 (equivalent to !(c1<c2))

元素位置操作:
count (elem)                    Returns the number of elements with value elem
find(elem)                        Returns the position of the first element with value elem or end()
lower _bound(elem)        Returns the first position, where elem would get inserted (the first element>= elem)
upper _bound(elem)       Returns the last position, where elem would get inserted (the firstelement > elem)
equal_range(elem)          Returns the first and last position, where elem would get inserted (the range of elements == elem)

Swap 操作:
c1 = c2            Assigns all elements of c2 to c1
c1.swap(c2)     Swaps the data of c1 and c2
swap(c1,c2)     Same (as global function)

iterators Operator
c.begin()           Returns a bidirectional iterator for the first element (elements are considered const)
c.end()             Returns a bidirectional iterator for the position after the last element (elements are considered const)
c.rbegin()          Returns a reverse iterator for the first element of a reverse iteration
c.rend()             Returns a reverse iterator for the position after the last element of a reverse teration

Insert ,Erase,Clear Operators
c. insert(elem)            Inserts a copy of elem and returns the position of the new element and,for sets, whether it succeeded
c. insert(pos,elem)     Inserts a copy of elem and returns the position of the new element 
c. insert(beg,end)      Inserts a copy of all elements of the range [beg,end) (returns nothing)
c. erase(elem)          Removes all elements with value elem and returns the number of removed elements
c. erase(pos)            Removes the element at iterator position pos (returns nothing)
c.erase(beg,end)      Removes all elements of the range [beg,end) (returns nothing)
c. clear()                 Removes all elements (makes the container empty)

Set对元素的要求,默认构造函数,Operator<,赋值操作法,拷贝构造函数,Operator==,在析构函数里处理掉。
内容概要:本文围绕动态环境下多无人机系统的协同路径规划与防撞展开研究,提出基于Matlab代码实现的解决方案。重点研究在复杂、动态变化的环境中,多架无人机如何通过协同算法实现高效路径规划,并有效避免相互之间的碰撞。文中采用先进的优化算法与避障策略,结合仿真验证,展示了系统在实时性、安全性与协同效率方面的性能表现。研究涵盖环境建模、路径规划算法设计、冲突检测与规避机制等关键环节,通过Matlab平台完成算法实现与仿真测试,具有较强的可复现性和工程应用价值。; 适合人群:具备一定Matlab编程能力,从事无人机控制、智能交通、自动化或相关领域研究的科研人员及研究生;对路径规划、多智能体协同、避障算法感兴趣的技术人员。; 使用场景及目标:①用于多无人机系统在复杂动态环境下的协同任务执行,如搜救、巡检、编队飞行等;②为研究人员提供可复现的Matla动态环境下多无人机系统的协同路径规划与防撞研究(Matlab代码实现)b代码框架,支持进一步算法改进与对比实验;③帮助理解协同路径规划与防撞机制的设计思路与实现细节。; 阅读建议:建议结合提供的Matlab代码进行逐模块分析,重点关注路径规划算法与防撞逻辑的实现方式,配合仿真结果加深理解;可在此基础上扩展不同环境场景或引入更复杂的动力学模型以提升实用性。
内容概要:本文详细介绍了一个基于Java和Vue的物联网冷链仓储监控与预警平台的设计与实现,涵盖了从项目背景、目标、系统架构、功能模块、数据库设计、前后端代码实现到部署应用的完整开发流程。平台通过物联网技术实现对冷链仓库环境参数(如温度、湿度、气体浓度)的实时采集与智能监控,结合云端大数据分析与AI预警算法,提供多级预警、设备联动、可视化大屏、报表导出等功能,支持生鲜食品、医药疫苗、化工危险品等多个行业的冷链管理需求。系统采用Spring Boot + Vue的前后端分离架构,具备高可扩展性、安全合规性和跨平台接入能力。; 适合人群:具备Java和Vue开发基础的中高级研发人员,熟悉Spring Boot、MySQL、RESTful API及前端框架的开发者,以及从事物联网、智能仓储、冷链物流等相关领域的技术人员。; 使用场景及目标:①构建企业级冷链仓储监控系统,实现实时数据采集与异常预警;②学习大型项目全栈开发流程,掌握前后端协同、数据库设计与API规范;③应用于医药、食品、化工等行业,提升仓储管理的智能化、数字化水平,保障货品质量安全。; 阅读建议:建议结合文中提供的完整代码、数据库脚本和API接口文档进行实践操作,重点关注系统架构设计、物联网数据处理流程及前后端交互逻辑,建议在本地或云环境部署项目以深入理解其运行机制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值