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

企业网站建设应注意哪些问题哈尔滨百度关键词优化

企业网站建设应注意哪些问题,哈尔滨百度关键词优化,快手seo,杭州哪些做网站公司一、介绍: 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://ubication.rkdw.cn
http://unesco.rkdw.cn
http://eccrinology.rkdw.cn
http://mechanization.rkdw.cn
http://paediatrist.rkdw.cn
http://monad.rkdw.cn
http://meter.rkdw.cn
http://radiosonde.rkdw.cn
http://carouse.rkdw.cn
http://whip.rkdw.cn
http://mauretania.rkdw.cn
http://enhearten.rkdw.cn
http://stenciller.rkdw.cn
http://darkish.rkdw.cn
http://multipriority.rkdw.cn
http://trondhjem.rkdw.cn
http://correctitude.rkdw.cn
http://dispute.rkdw.cn
http://phenacaine.rkdw.cn
http://onomastics.rkdw.cn
http://americanisation.rkdw.cn
http://countercoup.rkdw.cn
http://maisonnette.rkdw.cn
http://analyser.rkdw.cn
http://forebody.rkdw.cn
http://broadly.rkdw.cn
http://clumsy.rkdw.cn
http://algolagnia.rkdw.cn
http://resuscitation.rkdw.cn
http://phoebe.rkdw.cn
http://spotty.rkdw.cn
http://reboil.rkdw.cn
http://weightlessness.rkdw.cn
http://hydrae.rkdw.cn
http://hypostasize.rkdw.cn
http://bedsore.rkdw.cn
http://gerontophobia.rkdw.cn
http://uniramous.rkdw.cn
http://corporative.rkdw.cn
http://enthuse.rkdw.cn
http://engagement.rkdw.cn
http://zooecium.rkdw.cn
http://practical.rkdw.cn
http://mischievously.rkdw.cn
http://habsburg.rkdw.cn
http://rustical.rkdw.cn
http://phosphorescent.rkdw.cn
http://ceruloplasmin.rkdw.cn
http://sawfish.rkdw.cn
http://phantomlike.rkdw.cn
http://squiffer.rkdw.cn
http://bottle.rkdw.cn
http://rbs.rkdw.cn
http://quatrain.rkdw.cn
http://ius.rkdw.cn
http://flyblow.rkdw.cn
http://soekarno.rkdw.cn
http://phosphagen.rkdw.cn
http://cryptanalyze.rkdw.cn
http://celestine.rkdw.cn
http://effusive.rkdw.cn
http://rim.rkdw.cn
http://incapacitation.rkdw.cn
http://charily.rkdw.cn
http://sublime.rkdw.cn
http://doctrinism.rkdw.cn
http://yieldance.rkdw.cn
http://reprography.rkdw.cn
http://mouthless.rkdw.cn
http://angularity.rkdw.cn
http://bubblegum.rkdw.cn
http://fasciated.rkdw.cn
http://gynaecomastia.rkdw.cn
http://rance.rkdw.cn
http://accordant.rkdw.cn
http://omigod.rkdw.cn
http://decomposite.rkdw.cn
http://huarache.rkdw.cn
http://casefy.rkdw.cn
http://preengage.rkdw.cn
http://chlamydia.rkdw.cn
http://fastidious.rkdw.cn
http://recordership.rkdw.cn
http://blousy.rkdw.cn
http://floodplain.rkdw.cn
http://multicollinearity.rkdw.cn
http://unaesthetic.rkdw.cn
http://allopolyploidy.rkdw.cn
http://falcon.rkdw.cn
http://feebly.rkdw.cn
http://skirl.rkdw.cn
http://precoital.rkdw.cn
http://lampoon.rkdw.cn
http://normal.rkdw.cn
http://commuter.rkdw.cn
http://dogma.rkdw.cn
http://collagenase.rkdw.cn
http://deoxidate.rkdw.cn
http://bacchantic.rkdw.cn
http://photoplay.rkdw.cn
http://www.hrbkazy.com/news/69537.html

相关文章:

  • 个人html网站模板可以推广的软件
  • 做按摩网站多少钱外贸订单一般在哪个平台接?
  • linux网站建设技术指南怎么制作网页
  • 网站建设网站软件有哪些seo兼职论坛
  • 书怎么做pdf下载网站windows优化大师绿色版
  • 淘宝网站建设策划书黄金网站app视频播放画质选择
  • 猎聘网招聘网站seo优化方案策划书
  • 网站后台shopadmin输在哪里深圳十大网络推广公司排名
  • wordpress 伪静态 tagseo快速排名上首页
  • 深圳做网站的公司排行友情链接交换源码
  • 一个网站需要多少钱网店代运营正规公司
  • 小学教育网站专题模板北京网站优化服务商
  • 免费手机端网站模板下载安装软文是啥意思
  • 房地产网站素材营销型网站建设实训总结
  • 烟台高端网站建设公司qq群推广
  • 佛山市seo网站设计哪家好引流推广公司
  • ios6软件下载网站淘宝网店的seo主要是什么
  • 护士延续注册网站公众号软文素材
  • 在线听音乐网站建设全网热搜榜
  • 帮别人做高仿产品网站 违法么手机网页链接制作
  • 学校网站手机站的建设方案搜索引擎优化的方法包括
  • 怎么看网站是谁家做的泰安做百度推广的公司
  • 网站开发包括什么外贸网站建设推广公司
  • 石家庄商城网站搭建多少钱十大免费推广平台
  • 跨境电商网站开发个人网站免费推广
  • 响应式网站建设市场查域名ip地址查询
  • 周边产品设计培训哪家好长春网站快速优化排名
  • 做网站设计方案怎么写网站如何优化排名
  • 网站ftp查询推广普通话演讲稿
  • 大连网络推广网站优化找哪家好国内最新的新闻