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

魔方网站建设网站制作seo现在还有前景吗

魔方网站建设网站制作,seo现在还有前景吗,全国企业信息查询系统入口官网,如何制作统计小程序迭代器模式 介绍 设计模式定义案例迭代器模式行为型:关注对象与行为的分离 提供了一种统一的方式来访问多个不同的集合两个集合:使用了不同的数据存储方式 学生 和 警察 查询显示出集合的内容 ,使用相同的代码 问题堆积在哪里解决办法不同…

迭代器模式

介绍

设计模式定义案例
迭代器模式行为型:关注对象与行为的分离
提供了一种统一的方式来访问多个不同的集合
两个集合:使用了不同的数据存储方式
学生 和 警察

查询显示出集合的内容 ,使用相同的代码
问题堆积在哪里解决办法
不同的存储方式

统一集合查询代码
1 统一出一个存储方式
2 设计一个查询基类来统一查询代码
3 每个集合提供
  1 统一存储方式,
  2 一个查询实现(接口迭代器的实现)

类图

代码

interface BaseIterator<T>

/// <summary>
/// 迭代器基类
/// </summary>
public interface BaseIterator<T>
{// 当前T Current();// 下一个bool MoveNext();// 重新开始void Reset();
}

IteratorPolice 

using System.Collections.Generic;public class IteratorPolice : BaseIterator<People>
{// 列表List<People> listPeople = null;// 下标int currentIndex = -1;  IteratorPolice() { }public IteratorPolice(List<People> 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 : BaseIterator<People>
{// 列表List<People> listPeople = null;// 下标int currentIndex = -1;IteratorStudent() { }public IteratorStudent(List<People> 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 List<People> list = new List<People>();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 BaseIterator<People> GetIterator(){return new IteratorStudent(list);}
}

PoliceList


using System.Collections.Generic;public class PoliceList
{private List<People> list = new List<People>();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 BaseIterator<People> GetIterator(){return new IteratorPolice(list); }
}

测试代码

using UnityEngine;public class TestDDQ : MonoBehaviour
{void Start(){{PoliceList pl = new PoliceList();BaseIterator<People> iterator = pl.GetIterator();while (iterator.MoveNext()){People p1 = iterator.Current();Debug.Log("姓名:" + p1.name + "   年龄:" + p1.age + "   是否结婚:" + p1.married + " ");}}Debug.Log("------------------------------------------------------------------");{StudentList pl = new StudentList();BaseIterator<People> iterator = pl.GetIterator();while (iterator.MoveNext()){People p1 = iterator.Current();Debug.Log("姓名:" + p1.name + "   年龄:" + p1.age + "   是否结婚:" + p1.married + " ");}}}
}

结果

总结

迭代器模式统一集合查询代码,以这个为目标进现优化总结出的一个经验。

还是为了更深刻的理解设计原理和优化手段。

http://www.hkea.cn/news/870639/

相关文章:

  • 通用搭建网站教程优化营商环境的意义
  • 网站中加入地图怎样优化网站排名
  • 网站如何被搜索引擎收录地推推广平台
  • 池州做网站公司游戏搜索风云榜
  • 东丽区做网站网站查询平台
  • wordpress什么主题好用seo优化范畴
  • 局域网端口映射做网站西安竞价托管代运营
  • 重庆网站建设设计公司信息ip网站查询服务器
  • 网站积分的作用seo搜索引擎优化就业前景
  • 珠海网站品牌设计公司简介最新国内新闻重大事件
  • 广东专业网站客服软件定制站长统计app下载大全
  • 广东网站建设公司排名磁力帝
  • 胶南网站建设哪家好成都电脑培训班零基础
  • 集团网站建设哪家好网上推广怎么弄?
  • dz网站建设器最近有新病毒出现吗
  • 个人网站制作说明香港旺道旺国际集团
  • 监控做直播网站免费网站seo
  • 网站建设洪塔网站搜索优化排名
  • 专业做设计师品牌网站深圳百度总部
  • 网站兼容工具seo关键词排名优化教程
  • O2O网站制作需要多少钱美区下载的app怎么更新
  • 上海做网站 公司做电商必备的几个软件
  • caozi.com网站建设中百度指数如何分析数据
  • 互联网舆情处置公司武汉seo外包平台
  • 消防器材网站建设背景seo工作职位
  • 专业网站制作公司名称seo咨询茂名
  • 做b2c网站建网站seo
  • 代理注册香港公司seo技术交流论坛
  • 想要提高网站排名应该怎么做seo网站推广费用
  • 专业做食材网站seo链接优化建议