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

响应式网站新闻部分怎么做襄阳百度开户

响应式网站新闻部分怎么做,襄阳百度开户,网站域名后缀有什么用,自助建站一般适用于大型电子商务网站建设迭代器模式 介绍 设计模式定义案例迭代器模式行为型#xff1a;关注对象与行为的分离 提供了一种统一的方式来访问多个不同的集合两个集合#xff1a;使用了不同的数据存储方式 学生 和 警察 查询显示出集合的内容 #xff0c;使用相同的代码 问题堆积在哪里解决办法不同…迭代器模式 介绍 设计模式定义案例迭代器模式行为型关注对象与行为的分离 提供了一种统一的方式来访问多个不同的集合两个集合使用了不同的数据存储方式 学生 和 警察 查询显示出集合的内容 使用相同的代码 问题堆积在哪里解决办法不同的存储方式 统一集合查询代码1 统一出一个存储方式 2 设计一个查询基类来统一查询代码 3 每个集合提供   1 统一存储方式   2 一个查询实现接口迭代器的实现 类图 代码 interface BaseIteratorT /// summary /// 迭代器基类 /// /summary public interface BaseIteratorT {// 当前T Current();// 下一个bool MoveNext();// 重新开始void Reset(); }IteratorPolice  using System.Collections.Generic;public class IteratorPolice : BaseIteratorPeople {// 列表ListPeople listPeople null;// 下标int currentIndex -1; IteratorPolice() { }public IteratorPolice(ListPeople list){listPeople list;}public People Current(){if (null listPeople)return null;if (listPeople.Count currentIndex)return null;return listPeople[currentIndex];}public bool MoveNext(){if (null listPeople)return false;if (listPeople.Count currentIndex)return true;return false;}public void Reset(){currentIndex -1;} }IteratorStudent  using System.Collections.Generic;public class IteratorStudent : BaseIteratorPeople {// 列表ListPeople listPeople null;// 下标int currentIndex -1;IteratorStudent() { }public IteratorStudent(ListPeople list){listPeople list;}public People Current(){if (null listPeople)return null;if (listPeople.Count currentIndex)return null;return listPeople[currentIndex];}public bool MoveNext(){if (null listPeople)return false;if (listPeople.Count currentIndex)return true;return false;}public void Reset(){currentIndex -1;}}People public class People {public string name;public int age;public bool married; }StudentList using System.Collections; using System.Collections.Generic; using UnityEngine;public class StudentList {private ListPeople list new ListPeople();private People[] studentList new People[3];public StudentList(){People p1 new People(){name WH,age 15,married false};studentList[0] p1;People p2 new People(){name QT,age 16,married false};studentList[1] p2;People p3 new People(){name YY,age 15,married false};studentList[2] p3;for (int i 0; i studentList.Length; i){list.Add(studentList[i]);}}public BaseIteratorPeople GetIterator(){return new IteratorStudent(list);} }PoliceList using System.Collections.Generic;public class PoliceList {private ListPeople list new ListPeople();public PoliceList(){People p1 new People(){name WangQiang,age 23,married false};list.Add(p1);People p2 new People(){name ZhangQiang,age 30,married true};list.Add(p2);People p3 new People(){name LingQiang,age 31,married true};list.Add(p3);}public BaseIteratorPeople GetIterator(){return new IteratorPolice(list); } }测试代码 using UnityEngine;public class TestDDQ : MonoBehaviour {void Start(){{PoliceList pl new PoliceList();BaseIteratorPeople iterator pl.GetIterator();while (iterator.MoveNext()){People p1 iterator.Current();Debug.Log(姓名 p1.name 年龄 p1.age 是否结婚 p1.married );}}Debug.Log(------------------------------------------------------------------);{StudentList pl new StudentList();BaseIteratorPeople iterator pl.GetIterator();while (iterator.MoveNext()){People p1 iterator.Current();Debug.Log(姓名 p1.name 年龄 p1.age 是否结婚 p1.married );}}} } 结果 总结 迭代器模式统一集合查询代码以这个为目标进现优化总结出的一个经验。 还是为了更深刻的理解设计原理和优化手段。
http://www.hkea.cn/news/14452056/

相关文章:

  • 深圳网站 商城制作软件开发流程流程图
  • 做公众号app,网站,app网站建设公司哪些主要哪些
  • 成都专业网站营销wordpress 注册会员
  • 网站的功能板块广告公司企业简介怎么写
  • 网站地图做关键词排名设计师门户网站程序
  • 如何做淘客发单网站做网站哪家服务器好
  • 温岭市建设工程质量安全网站如何让自己做的网页有网站
  • 湿地公园网站建设一个免费的网站
  • 湖南省网站太原论坛
  • 论坛网站免费建设模板光之翼可以做网站吗
  • 超能力联盟网站养一个空壳公司的好处
  • 社交网站推广怎么做网建什么意思
  • 固定ip做网站和域名区别网站设计确认
  • 动易 网站顶部导航 sitefactory免费设计签名的软件
  • 网站设计公司南京内乡微网站开发
  • 网站前台的网址快速网页制作工具
  • 关于申请网站建设WordPress主题使用域名加密
  • app推广平台网站凡科建站弊端
  • 企业查询网站企查查营销型网站代理
  • 宁波网站建设制作公司排名2015微信网站
  • 深圳专业建站平台怎么做直播网站的超管
  • 做风筝网站企业网络服务
  • 如何搭建asp网站app开发需要多少费用
  • 免费下载的appseo服务优化
  • 医药网站建设需要注意点百度seo优化教程
  • 北京免费自己制作网站公司免费招聘网站
  • 关于写策划的一个网站wordpress微信支付购买课程
  • 南浔区住房和城乡建设局网站网站建设入门培训
  • 追星做网站wordpress 仿牛杂
  • 如何做网站建设方案企业网络推广最简单方法