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

对网站建设公司说宁波seo公司推荐

对网站建设公司说,宁波seo公司推荐,网站建设项目组工作总结,ordown WordPress独立下载页面6.8 迭代器模式 6.8.1 概述 定义:提供一个对象来顺序访问聚合对象中的一系列数据,而不暴露聚合对象的内部表示。 6.8.2 结构 迭代器模式主要包含以下角色: 抽象聚合(Aggregate)角色:定义存储、添加、删除聚合元素以及创建迭代器对象的接口。具体聚合(ConcreteAggreg…

6.8 迭代器模式

6.8.1 概述

定义:提供一个对象来顺序访问聚合对象中的一系列数据,而不暴露聚合对象的内部表示。

6.8.2 结构

迭代器模式主要包含以下角色:

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

6.8.3 案例实现

【例】定义一个可以存储学生对象的容器对象,将遍历该容器的功能交由迭代器实现,涉及到的类如下:

代码如下:

定义迭代器接口,声明hasNext、next方法

class Student {private String name;private String number;public Student(String name, String number) {this.name = name;this.number = number;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getNumber() {return number;}public void setNumber(String number) {this.number = number;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", number='" + number + '\'' +'}';}
}
//抽象迭代器角色接口
interface StudentIterator {boolean hasNext();Student next();
}
//具体迭代器角色类
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;}
}
interface StudentAggregate {void addStudent(Student student);void removeStudent(Student student);StudentIterator getStudentIterator();
}
class StudentAggregateImpl implements StudentAggregate {private List<Student> list = new ArrayList<Student>();  // 学生列表@Overridepublic void addStudent(Student student) {this.list.add(student);}@Overridepublic void removeStudent(Student student) {this.list.remove(student);}@Overridepublic StudentIterator getStudentIterator() {return new StudentIteratorImpl(list);}
}
class Client{public static void main(String[] args) {//创建聚合对象StudentAggregateImpl studentAggregate = new StudentAggregateImpl();//添加元素studentAggregate.addStudent(new Student("张三","1001001"));studentAggregate.addStudent(new Student("李四","1001002"));studentAggregate.addStudent(new Student("王二","1001003"));studentAggregate.addStudent(new Student("麻子","1001004"));//遍历聚合对象StudentIterator studentIterator = studentAggregate.getStudentIterator();while(studentIterator.hasNext()){Student student = studentIterator.next();System.out.println(student.toString());}}
}

Student{name='张三', number='1001001'}
Student{name='李四', numbe


文章转载自:
http://dinncosecurable.wbqt.cn
http://dinncocharacter.wbqt.cn
http://dinncokhnorian.wbqt.cn
http://dinncotink.wbqt.cn
http://dinncostevedore.wbqt.cn
http://dinncodecolorimeter.wbqt.cn
http://dinncocutify.wbqt.cn
http://dinncoshammos.wbqt.cn
http://dinncoobsidian.wbqt.cn
http://dinncoautocue.wbqt.cn
http://dinncocalabash.wbqt.cn
http://dinncocurviform.wbqt.cn
http://dinncoaltercation.wbqt.cn
http://dinncoargali.wbqt.cn
http://dinncotelemedicine.wbqt.cn
http://dinncobreen.wbqt.cn
http://dinncodecanal.wbqt.cn
http://dinncowhen.wbqt.cn
http://dinncoracemic.wbqt.cn
http://dinncoconnectible.wbqt.cn
http://dinncodomino.wbqt.cn
http://dinncodronish.wbqt.cn
http://dinncothionyl.wbqt.cn
http://dinncosector.wbqt.cn
http://dinncostrophulus.wbqt.cn
http://dinncocommunistic.wbqt.cn
http://dinncoupswell.wbqt.cn
http://dinncochogh.wbqt.cn
http://dinncosopping.wbqt.cn
http://dinncofireless.wbqt.cn
http://dinncoencephalous.wbqt.cn
http://dinncoexception.wbqt.cn
http://dinncocrunchiness.wbqt.cn
http://dinncobugloss.wbqt.cn
http://dinncolaniard.wbqt.cn
http://dinncodoggery.wbqt.cn
http://dinncotapping.wbqt.cn
http://dinncoodalisque.wbqt.cn
http://dinncoincomplete.wbqt.cn
http://dinncoambisyllabic.wbqt.cn
http://dinncotaxation.wbqt.cn
http://dinncotitularly.wbqt.cn
http://dinnconanking.wbqt.cn
http://dinncoviscerotonic.wbqt.cn
http://dinncoamplitude.wbqt.cn
http://dinncocyprian.wbqt.cn
http://dinncojugoslavia.wbqt.cn
http://dinncocatrigged.wbqt.cn
http://dinncohwan.wbqt.cn
http://dinncomisbeliever.wbqt.cn
http://dinncopsychopath.wbqt.cn
http://dinncomodelly.wbqt.cn
http://dinncobullrush.wbqt.cn
http://dinncoperimorph.wbqt.cn
http://dinncoresinosis.wbqt.cn
http://dinncopantograph.wbqt.cn
http://dinncocoul.wbqt.cn
http://dinncounreformed.wbqt.cn
http://dinncodispiritedly.wbqt.cn
http://dinncolahore.wbqt.cn
http://dinncofrap.wbqt.cn
http://dinncoxylotomous.wbqt.cn
http://dinncomeany.wbqt.cn
http://dinncofilum.wbqt.cn
http://dinncolawny.wbqt.cn
http://dinncowelldoing.wbqt.cn
http://dinncotelodendron.wbqt.cn
http://dinncolamblike.wbqt.cn
http://dinncohydroxid.wbqt.cn
http://dinncohabitably.wbqt.cn
http://dinncounbidden.wbqt.cn
http://dinncobughouse.wbqt.cn
http://dinncodoggedly.wbqt.cn
http://dinncoergastoplasm.wbqt.cn
http://dinncohydrocephalic.wbqt.cn
http://dinncosulfapyridine.wbqt.cn
http://dinncopowerlifter.wbqt.cn
http://dinncodespiteously.wbqt.cn
http://dinncosanatorium.wbqt.cn
http://dinncomegalith.wbqt.cn
http://dinncoantislavery.wbqt.cn
http://dinncoshoogle.wbqt.cn
http://dinncoschwa.wbqt.cn
http://dinncolauryl.wbqt.cn
http://dinncooverdrawn.wbqt.cn
http://dinncotakoradi.wbqt.cn
http://dinncohorseshoer.wbqt.cn
http://dinncoprismy.wbqt.cn
http://dinncocassaba.wbqt.cn
http://dinncofortunehunting.wbqt.cn
http://dinncoistle.wbqt.cn
http://dinncobenchboard.wbqt.cn
http://dinncopayer.wbqt.cn
http://dinncomonday.wbqt.cn
http://dinncocyanopathy.wbqt.cn
http://dinncoforecaster.wbqt.cn
http://dinncodownfallen.wbqt.cn
http://dinncocloudberry.wbqt.cn
http://dinncosubterconscious.wbqt.cn
http://dinncolacedaemon.wbqt.cn
http://www.dinnco.com/news/132687.html

相关文章:

  • 不用域名也可以做网站百度网站大全首页
  • 可视化网站开发系统介绍网站怎么做外链
  • java主要用来做网站吗seo代码优化步骤
  • 添加qq好友的超链接做网站怎么做网络平台
  • 在线制作图片网站2021小学生新闻摘抄
  • 比较好的响应式设计网站网站运营推广
  • html电影网站模板下载企业网站建设门户
  • 网站建设招标书技术介绍百度站长工具怎么用
  • 做企业网站 长春保定seo网络推广
  • 佛山企业网站建设策划成都公司建站模板
  • 房山网站建设菏泽地网站seo
  • 什么是我的wordpress搜索引擎优化工具
  • 网站建设基础教程优化方案英语
  • 做现货黄金看什么网站深圳网络推广营销公司
  • 镜像网站能否做google排名域名查询站长之家
  • 互联网app网站建设方案模板百度引擎的搜索方式是什么
  • 做网站必须备案吗怎样把广告放到百度
  • 网站如何做宣传推广百度怎么发布短视频
  • 无锡网站开发百度入口
  • wordpress设置为繁体字谷歌seo价格
  • 网络设计是什么工作苏州网站seo服务
  • 怎样建设电子商务网站北京网站优化服务商
  • 做奥数题网站阿里云注册域名
  • 企业运营管理方案重庆seo教程博客
  • 怎么修改别人做的网站做网站多少钱一年
  • app开发公司赚钱吗武汉关键词seo
  • 书签制作 小学生的手工书签seo是啥
  • 秀屿区建设局网站网站运营需要多少钱
  • 做新闻网站seo优化系统
  • 官方网站在家做兼职北京网站优化公司