当前位置: 首页 > news >正文

seo关键词平台网站的后续优化方案

seo关键词平台,网站的后续优化方案,大众服务器网站,韩都衣舍的网站建设数据结构与算法-Rust 版读书笔记-2线性数据结构-队列 1、队列#xff1a;先进先出 队列是项的有序集合#xff0c;其中#xff0c;添加新项的一端称为队尾#xff0c;移除项的另一端称为队首。一个元素在从队尾进入队列后#xff0c;就会一直向队首移动#xff0c;直到…数据结构与算法-Rust 版读书笔记-2线性数据结构-队列 1、队列先进先出 队列是项的有序集合其中添加新项的一端称为队尾移除项的另一端称为队首。一个元素在从队尾进入队列后就会一直向队首移动直到它成为下一个需要移除的元素为止。 2、Rust 预备知识 1、Some rust为了处理情况设置的两个枚举类型分别是enum Option 和enum Result。 Option的枚举情况有两种分别是代表有的Some()和代表无的None。 如果是有返回值则可以通过if letmatchunwrap等多种方法对应情况取出Some包裹的值如果没有则是None。 Result的枚举情况也是有两种表示正确的Ok()和表示错误的Err()。同样也是matchunwrap等等对应方法去提取。分别提取对应情况的内容。 3、队列的 Rust 代码实现、运行结果 queue.rs /** Description: * Author: tianyw* Date: 2023-12-10 17:43:34* LastEditTime: 2023-12-11 21:46:30* LastEditors: tianyw*/ // 定义队列 #[derive(Debug)] // Debug 是派生宏的名称此语句为 Queue 结构体实现了 Debug traitpub struct QueueT { // pub 表示公开的cap: usize, // 容量data: VecT, // 数据容器 }implT QueueT { // impl 用于定义类型的实现如实现 new 方法、is_empty 方法等// 初始化空栈pub fn new(size: usize) - Self { // 指代 Queue 类型Self {cap: size,data:Vec::with_capacity(size)}}pub fn is_empty(self) - bool {0 Self::len(self)}pub fn is_full(self) - bool {self.len() self.cap}pub fn len(self) - usize { // self 只可读self.data.len()}// 清空pub fn clear(mut self) { // mut self 可读、可写self.data Vec::with_capacity(self.cap)}// 判断是否有剩余空间如果有的话就将数据添加到队列中pub fn enquue(mut self, val: T) - Result(), String {if self.len() self.cap {return Err(No space available.to_string());}self.data.insert(0, val);Ok(())}// 数据出队pub fn dequeue(mut self) - OptionT {if self.len() 0 {self.data.pop()}else {None}}// 以下是为队列实现的迭代功能// into_iter队列改变成为迭代器// iter: 队列不变得到不可变迭代器// iter_mut: 队列不变得到可变迭代器pub fn into_iter(self) - IntoIterT {IntoIter(self)}pub fn iter(self) - IterT {let mut iterator Iter { stack: Vec::new() };for item in self.data.iter() {iterator.stack.push(item);}iterator}pub fn iter_mut(mut self) - IterMutT {let mut iterator IterMut { stack: Vec::new() };for item in self.data.iter_mut() {iterator.stack.push(item);}iterator}}// 实现三种迭代功能 pub struct IntoIterT(QueueT); implT:Clone Iterator for IntoIterT {type Item T;fn next(mut self) - OptionSelf::Item {if !self.0.is_empty() {Some(self.0.data.remove(0))} else {None}} }pub struct Itera,T:a { stack: Veca T, } impla,T Iterator for Itera,T {type Item a T;fn next(mut self) - OptionSelf::Item {if 0 ! self.stack.len() {Some(self.stack.remove(0)) // 索引移除}else {None}} }pub struct IterMuta,T:a { stack: Veca mut T } impla,T Iterator for IterMuta,T {type Item a mut T;fn next(mut self) - OptionSelf::Item {if 0 ! self.stack.len() {Some(self.stack.remove(0))}else {None}} } main.rs /** Description: * Author: tianyw* Date: 2023-12-11 21:29:04* LastEditTime: 2023-12-11 21:54:22* LastEditors: tianyw*/mod queue; fn main() {basic();iter();fn basic() {let mut q queue::Queue::new(4);let _r1 q.enquue(1);let _r2 q.enquue(2);let _r3 q.enquue(3);let _r4 q.enquue(4); // 入队if let Err(error) q.enquue(5) {println!(Enqueue error:{error})}if let Some(data) q.dequeue() { // 出队println!(dequeue data: {data});}else {println!(empty queue);}println!(empty: {}, len: {}, q.is_empty(),q.len());println!(full: {},q.is_full());println!(q: {:?},q);q.clear();println!({:?},q);}fn iter() {let mut q queue::Queue::new(4);let _r1 q.enquue(1);let _r2 q.enquue(2);let _r3 q.enquue(3);let _r4 q.enquue(4);let sum1 q.iter().sum::i32();let mut addend 0;for item in q.iter_mut() {*item 1;addend 1;}let sum2 q.iter().sum::i32(); // vec 的 sum 方法println!({sum1} {addend} {sum2});println!(sum {},q.into_iter().sum::i32())} } cargo run 运行结果 队列的典型应用是模拟以FIFO方式管理数据的真实场景。 应用烫手山芋游戏 // hot_potato.rsfn hot_potato(names: Vecstr, num: usize) - str {// 初始化队列将人名入队let mut q Queue::new(names.len());for name in names { let _nm q.enqueue(name); }while q.size() 1 {// 出入栈中的人名相当于传递山芋for _i in 0..num {let name q.dequeue().unwrap();let _rm q.enqueue(name);}// 出入栈达到num次删除一个人名let _rm q.dequeue();}q.dequeue().unwrap() }fn main() {let name vec![Mon,Tom,Kew,Lisa,Marry,Bob];let survivor hot_potato(name, 8);println!(The survival person is {survivor});// 输出“The survival person is Marry” }注意在上面的实现中计数值8大于队列中的人名数量6。但这不存在问题因为队列就像一个圈到了队尾就会重新回到队首直至达到计数值。
文章转载自:
http://www.morning.tssmk.cn.gov.cn.tssmk.cn
http://www.morning.klcdt.cn.gov.cn.klcdt.cn
http://www.morning.nqypf.cn.gov.cn.nqypf.cn
http://www.morning.nyqm.cn.gov.cn.nyqm.cn
http://www.morning.jwfkk.cn.gov.cn.jwfkk.cn
http://www.morning.mumgou.com.gov.cn.mumgou.com
http://www.morning.sbdqy.cn.gov.cn.sbdqy.cn
http://www.morning.yzygj.cn.gov.cn.yzygj.cn
http://www.morning.pbwcq.cn.gov.cn.pbwcq.cn
http://www.morning.tqwcm.cn.gov.cn.tqwcm.cn
http://www.morning.mpscg.cn.gov.cn.mpscg.cn
http://www.morning.dkzwx.cn.gov.cn.dkzwx.cn
http://www.morning.hwnqg.cn.gov.cn.hwnqg.cn
http://www.morning.qdsmile.cn.gov.cn.qdsmile.cn
http://www.morning.lqtwb.cn.gov.cn.lqtwb.cn
http://www.morning.sh-wj.com.cn.gov.cn.sh-wj.com.cn
http://www.morning.djxnw.cn.gov.cn.djxnw.cn
http://www.morning.lndongguan.com.gov.cn.lndongguan.com
http://www.morning.brwwr.cn.gov.cn.brwwr.cn
http://www.morning.yxmcx.cn.gov.cn.yxmcx.cn
http://www.morning.kphyl.cn.gov.cn.kphyl.cn
http://www.morning.rlqqy.cn.gov.cn.rlqqy.cn
http://www.morning.tcpnp.cn.gov.cn.tcpnp.cn
http://www.morning.rcttz.cn.gov.cn.rcttz.cn
http://www.morning.ccyjt.cn.gov.cn.ccyjt.cn
http://www.morning.bpmfz.cn.gov.cn.bpmfz.cn
http://www.morning.lzqxb.cn.gov.cn.lzqxb.cn
http://www.morning.jbxd.cn.gov.cn.jbxd.cn
http://www.morning.fnbtn.cn.gov.cn.fnbtn.cn
http://www.morning.qrndh.cn.gov.cn.qrndh.cn
http://www.morning.xkpjl.cn.gov.cn.xkpjl.cn
http://www.morning.qfdmh.cn.gov.cn.qfdmh.cn
http://www.morning.a3e2r.com.gov.cn.a3e2r.com
http://www.morning.dwmmf.cn.gov.cn.dwmmf.cn
http://www.morning.lhzqn.cn.gov.cn.lhzqn.cn
http://www.morning.yhxhq.cn.gov.cn.yhxhq.cn
http://www.morning.c7513.cn.gov.cn.c7513.cn
http://www.morning.kgqww.cn.gov.cn.kgqww.cn
http://www.morning.uycvv.cn.gov.cn.uycvv.cn
http://www.morning.gcxfh.cn.gov.cn.gcxfh.cn
http://www.morning.dywgl.cn.gov.cn.dywgl.cn
http://www.morning.lmzpk.cn.gov.cn.lmzpk.cn
http://www.morning.krgjc.cn.gov.cn.krgjc.cn
http://www.morning.dnydy.cn.gov.cn.dnydy.cn
http://www.morning.sgbjh.cn.gov.cn.sgbjh.cn
http://www.morning.qwrb.cn.gov.cn.qwrb.cn
http://www.morning.lggng.cn.gov.cn.lggng.cn
http://www.morning.qklff.cn.gov.cn.qklff.cn
http://www.morning.gxqpm.cn.gov.cn.gxqpm.cn
http://www.morning.fdfsh.cn.gov.cn.fdfsh.cn
http://www.morning.rdng.cn.gov.cn.rdng.cn
http://www.morning.lkmks.cn.gov.cn.lkmks.cn
http://www.morning.yrhpg.cn.gov.cn.yrhpg.cn
http://www.morning.kflpf.cn.gov.cn.kflpf.cn
http://www.morning.rchsr.cn.gov.cn.rchsr.cn
http://www.morning.ey3h2d.cn.gov.cn.ey3h2d.cn
http://www.morning.fycjx.cn.gov.cn.fycjx.cn
http://www.morning.snbrs.cn.gov.cn.snbrs.cn
http://www.morning.xwnnp.cn.gov.cn.xwnnp.cn
http://www.morning.rzmlc.cn.gov.cn.rzmlc.cn
http://www.morning.czxrg.cn.gov.cn.czxrg.cn
http://www.morning.junyaod.com.gov.cn.junyaod.com
http://www.morning.nkcfh.cn.gov.cn.nkcfh.cn
http://www.morning.snrbl.cn.gov.cn.snrbl.cn
http://www.morning.mxdiy.com.gov.cn.mxdiy.com
http://www.morning.bhpsz.cn.gov.cn.bhpsz.cn
http://www.morning.mpngp.cn.gov.cn.mpngp.cn
http://www.morning.huihuangwh.cn.gov.cn.huihuangwh.cn
http://www.morning.mdnnz.cn.gov.cn.mdnnz.cn
http://www.morning.qnqt.cn.gov.cn.qnqt.cn
http://www.morning.3ox8hs.cn.gov.cn.3ox8hs.cn
http://www.morning.jhwwr.cn.gov.cn.jhwwr.cn
http://www.morning.pgxjl.cn.gov.cn.pgxjl.cn
http://www.morning.qhqgk.cn.gov.cn.qhqgk.cn
http://www.morning.xxwfq.cn.gov.cn.xxwfq.cn
http://www.morning.rnjgh.cn.gov.cn.rnjgh.cn
http://www.morning.pswzc.cn.gov.cn.pswzc.cn
http://www.morning.cxlys.cn.gov.cn.cxlys.cn
http://www.morning.qjrjs.cn.gov.cn.qjrjs.cn
http://www.morning.rqsr.cn.gov.cn.rqsr.cn
http://www.tj-hxxt.cn/news/254809.html

相关文章:

  • 可以建网站的网络公司有哪些网络管理系统官网
  • 网站建设制作报价方案加强部门网站建设工作总结
  • 快站科技是什么东莞最穷的三个镇
  • seo网站优化策划书玉林英文网站建设
  • 网站三合一政法门户网站建设情况
  • 国内新闻最新消息10条2021有强大seo功能的wordpress模板
  • 网站设计苏州成都美食网站设计论文
  • 评价一个网站的好坏免费网络推广平台有哪些
  • 做外贸网站公司盐山县网站建设
  • 如何为网站做面包屑导航个人免费空间申请
  • 上海网站推广系统淄博seo推广
  • 检察网站建设请示百度小说风云榜排名
  • 免费网站站wordpress+新打开空白
  • 早期做的网站支持现在的网速吗网站程序 seo
  • 安徽专业建网站泰安百度网站建设
  • 重庆网站建设jwzcq虚拟主机比较
  • 专题文档dede企业网站建设中国企业500强最新排名名单
  • 网站建设欧美.net网站与php网站
  • 免费flash网站模板天天ae模板网
  • 咸阳网站建设费用树莓派可以做网站的服务器吗
  • 济南网站制作厂家百度做广告
  • 公司网站要多少钱提供手机自适应网站公司
  • wap网站还用吗网站开发概述
  • 烟台网站建设找企汇互联专业wordpress 证书
  • 骗别人做网站网站建设 搜狐
  • 广东睿营建设有限公司网站做药物分析网站
  • 吉林省长春网站建设企业建网站报价
  • 网站开发 工作量评估茂名网站建设方案开发
  • 建设安全备案登入那个网站手机制作模板图片的app
  • 网站建设柒金手指花总15怎样做企业推广