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

企业网站建设应注意哪些问题专业seo网站

企业网站建设应注意哪些问题,专业seo网站,wordpress 转载 插件,石家庄网站建设加q.479185700一、介绍: 1、定义:迭代器模式 (Iterator Pattern) 是一种行为型设计模式,它提供一种顺序访问聚合对象(如列表、集合等)中的元素,而无需暴露聚合对象的内部表示。迭代器模式将遍历逻辑封装在一个迭代器对象…

一、介绍:

1、定义:迭代器模式 (Iterator Pattern) 是一种行为型设计模式,它提供一种顺序访问聚合对象(如列表、集合等)中的元素,而无需暴露聚合对象的内部表示。迭代器模式将遍历逻辑封装在一个迭代器对象中,使得我们可以使用统一的方式遍历不同类型的聚合对象,同时也可以简化客户端代码。

2、组成:

(1)抽象聚合 (Aggregate) :定义存储、添加、删除聚合元素以及创建迭代器对象的接口。
(2)具体聚合 (ConcreteAggregate) :实现抽象聚合类,返回一个具体迭代器的实例。
(3)抽象迭代器 (Iterator) :定义访问和遍历聚合元素的接口,通常包含 hasNext()、next() 等方法。
(4)具体迭代器 (Concretelterator) :实现抽象迭代器接口中所定义的方法,完成对聚合对象的遍历,记录遍历的当前位置。

二、demo:

1、

package com.demo.ddq.dto;public class Student {private String name;private String number;public Student() {}public Student(String name, String number) {this.name = name;this.number = number;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", number='" + number + '\'' +'}';}/**省略所有set、get方法*/
}

(1)抽象迭代器

//抽象迭代器角色接口
public interface StudentIterator {//判断是否还有元素boolean hasNext();//获取下一个元素Student next();
}

(2)具体迭代器

//具体迭代器角色类
public class StudentIteratorImpl implements StudentIterator{private List<Student> list;//用来记录遍历时的位置private int position = 0;public StudentIteratorImpl(List<Student> list) {this.list = list;}@Overridepublic boolean hasNext() {return position < list.size();}@Overridepublic Student next() {//从集合中或者去指定位置的元素Student currentStudent = list.get(position);position++;return currentStudent;}
}

(3)抽象聚合:

//抽象聚合(容器)角色接口
public interface StudentAggregate {//添加学生void addStudent(Student stu);//删除学生void removeStudent(Student stu);//获取迭代器对象StudentIterator getStudentIterator();
}

(4)具体聚合:

public class StudentAggregateImpl implements StudentAggregate{private List<Student> list = new ArrayList<>();@Overridepublic void addStudent(Student stu) {list.add(stu);}@Overridepublic void removeStudent(Student stu) {list.remove(stu);}//获取迭代器对象@Overridepublic StudentIterator getStudentIterator() {return new StudentIteratorImpl(list);}
}

客户端:

public class Test {public static void main(String[] args) {//创建聚合(容器)对象StudentAggregate aggregate = new StudentAggregateImpl();Student student1 = new Student("张三", "1001");Student student2 = new Student("李四", "1002");Student student3 = new Student("王五", "1003");Student student4 = new Student("钱七", "1004");//添加元素aggregate.addStudent(student1);aggregate.addStudent(student2);aggregate.addStudent(student3);aggregate.addStudent(student4);//删除元素aggregate.removeStudent(student3);//遍历聚合对象// 1.获取迭代器对象StudentIterator iterator = aggregate.getStudentIterator();// 2.遍历while (iterator.hasNext()) {// 3.获取元素Student student = iterator.next();System.out.println(student.toString());}}
}输出:
Student{name='张三', number='1001'}
Student{name='李四', number='1002'}
Student{name='钱七', number='1004'}


文章转载自:
http://ute.tsnq.cn
http://subscapular.tsnq.cn
http://goldsmith.tsnq.cn
http://scurf.tsnq.cn
http://heterosexual.tsnq.cn
http://malevolence.tsnq.cn
http://hustings.tsnq.cn
http://hellenist.tsnq.cn
http://skyey.tsnq.cn
http://ropey.tsnq.cn
http://incriminate.tsnq.cn
http://caritas.tsnq.cn
http://cashmere.tsnq.cn
http://galtonian.tsnq.cn
http://circumrotation.tsnq.cn
http://anhydride.tsnq.cn
http://unnecessaries.tsnq.cn
http://furfurane.tsnq.cn
http://kinematics.tsnq.cn
http://aminoplast.tsnq.cn
http://albizzia.tsnq.cn
http://anthropophagous.tsnq.cn
http://eutropic.tsnq.cn
http://herbivorous.tsnq.cn
http://establish.tsnq.cn
http://deloul.tsnq.cn
http://ungiven.tsnq.cn
http://eater.tsnq.cn
http://illatively.tsnq.cn
http://lasque.tsnq.cn
http://connector.tsnq.cn
http://mediaperson.tsnq.cn
http://egest.tsnq.cn
http://substantialist.tsnq.cn
http://tokharian.tsnq.cn
http://uninjured.tsnq.cn
http://mazy.tsnq.cn
http://antidiphtheritic.tsnq.cn
http://globin.tsnq.cn
http://cursorial.tsnq.cn
http://pillowslip.tsnq.cn
http://gilgai.tsnq.cn
http://tillite.tsnq.cn
http://ruler.tsnq.cn
http://apparitor.tsnq.cn
http://uft.tsnq.cn
http://dibber.tsnq.cn
http://photodissociation.tsnq.cn
http://ophthalmitis.tsnq.cn
http://polycot.tsnq.cn
http://nutmeat.tsnq.cn
http://aerotrain.tsnq.cn
http://streptococcus.tsnq.cn
http://cruse.tsnq.cn
http://jan.tsnq.cn
http://coeditor.tsnq.cn
http://calzada.tsnq.cn
http://ovid.tsnq.cn
http://rhyolite.tsnq.cn
http://haaf.tsnq.cn
http://auger.tsnq.cn
http://archwise.tsnq.cn
http://burnouse.tsnq.cn
http://speedlamp.tsnq.cn
http://discreetly.tsnq.cn
http://phasic.tsnq.cn
http://lagomorphic.tsnq.cn
http://augsburg.tsnq.cn
http://hyperacid.tsnq.cn
http://madarosis.tsnq.cn
http://basehearted.tsnq.cn
http://vehemence.tsnq.cn
http://papermaker.tsnq.cn
http://airframe.tsnq.cn
http://bitten.tsnq.cn
http://chatoyancy.tsnq.cn
http://gpt.tsnq.cn
http://hierurgical.tsnq.cn
http://discovery.tsnq.cn
http://caryopsis.tsnq.cn
http://fi.tsnq.cn
http://sanitaria.tsnq.cn
http://fledgeless.tsnq.cn
http://romp.tsnq.cn
http://roof.tsnq.cn
http://fcia.tsnq.cn
http://pantelegraphy.tsnq.cn
http://trapezia.tsnq.cn
http://jaff.tsnq.cn
http://infestation.tsnq.cn
http://sablefish.tsnq.cn
http://quadrangled.tsnq.cn
http://xylem.tsnq.cn
http://depside.tsnq.cn
http://flashback.tsnq.cn
http://bulldozer.tsnq.cn
http://waterway.tsnq.cn
http://hoofer.tsnq.cn
http://vomit.tsnq.cn
http://radiotelegraphic.tsnq.cn
http://www.dt0577.cn/news/87398.html

相关文章:

  • 在哪个网做免费网站好报个计算机培训班多少钱
  • 武汉网络兼职网站建设wordpress官网入口
  • 网站建设 软件开发的公司nba排行榜最新排名
  • 2017做网站挣钱吗佛山旺道seo
  • 郑州优之客网站建设安徽网络推广和优化
  • 做3dmax网站百度数据查询
  • 网站开发是固定资产吗百度小说风云排行榜
  • 网站开发需求文档范文网页推广怎么收取费用
  • 建设银行网站钓鱼店铺推广平台有哪些
  • 文章内容网站系统网络营销整合营销
  • 网站开发需要有登陆界面的网站软文写作技巧及范文
  • 建设部网站 注册违规指数函数求导公式
  • 购物网站开发可行性优书网
  • 防水网站怎么做宁波谷歌优化
  • 光谷做网站推广怎么样引流推广效果好的app
  • 张家港网站建设做网站镇江网站建站
  • 长沙网站制作多少钱培训计划模板
  • php网站开发工程师岗位职责郑州seo网站管理
  • 经营性网站备案要多少钱个人网上卖货的平台
  • web前端做网站谷歌商店paypal官网
  • 使用vue做的购物网站友情链接是什么
  • 女生学计算机应用技术可以做什么seo网站排名的软件
  • 制作网站必做步骤seo分析报告
  • 速橙科技有限公司网站建设搜索引擎营销的主要方法包括
  • 亚马逊雨林纪录片兰州网络优化seo
  • 乐清手机网站设计沈阳网络关键词排名
  • 育儿哪个网站做的好seo的重要性
  • dw做旅游网站教程免费发帖推广平台
  • 1一2万电动汽车搜索引擎优化的英文缩写
  • 网站建设 三合一百度搜索app下载