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

网站seo插件seo推广培训课程

网站seo插件,seo推广培训课程,做网上购物网站,网站建设选哪个好迭代器定义:迭代器不是一种集合,它是一种用于访问集合的方法。 迭代器需要通过集合对应的迭代器调用迭代器的方法来访问。 支持函数式编程风格,便于链式操作。 创建一个迭代器,相关代码如下: object Test {def mai…

迭代器定义:迭代器不是一种集合,它是一种用于访问集合的方法。

迭代器需要通过集合对应的迭代器调用迭代器的方法来访问。

支持函数式编程风格,便于链式操作。

创建一个迭代器,相关代码如下:

object Test {def main(args: Array[String]): Unit = {val list1 = List(1,2,3,4,5)//任务:输出每一个元素
//    list1.foreach(println)//任务:跳过前两个,从第3个开始输出//迭代器//1.创建一个迭代器(iterator)val it1 = list1.iteratorval it2 = it1.drop(2)//依次访问每个元素while (it2.hasNext){println(it2.next())}}
}

 运行结果如下:

 

drop:从当前位置开始,跳过指定数量的元素,得到新的迭代器

 take:从当前位置开始,取几个元素,得到新的迭代器

toList的作用:把迭代器中剩余的元素保存到一个List中

zip方法(拉链):把两个迭代器合成一下,得到新的迭代器,长度以短的为准

相关代码如下:

object Test {def main(args: Array[String]): Unit = {val list1 = List(1, 2, 3, 4, 5)//任务:输出每一个元素//list1.foreach(println)//任务:跳过前两个,从第3个开始输出//迭代器//1.创建一个迭代器(iterator)val it1 = list1.iteratorval it2 = it1.drop(2)//2.依次访问每个元素//  hasNext()是否有下一个//  next():得到当前的元素,并把迭代器向后移动一个位置while (it2.hasNext) {println(it2.next())}println(it2.hasNext)val list2 = List(1,2,3)val it3 = list2.iteratorit3.next()it3.next()it3.next()//it3.next() //NoSuchElementException 没有这个元素。迭代器移过头了!!!//迭代器的使用场景:Map,List,Set.....都可以使用迭代器来遍历val m1 = Map("11"->1,"22"->2)val s1 = Set("A","B","C")val it4 = s1.iteratorwhile (it4.hasNext){println(it4.next())}println("-"*20)//任务是:打印前3个val list4 = List(1,2,3,4,5,6,7)val it5 = list4.iterator//take:从当前的迭代器的位置开始,取n个元素val it6 = it5.take(3)while (it6.hasNext){println(it6.next())}//只输出4,5,6 跳过前3个,再取3个val it7 = list4.iterator.drop(3).take(3)while (it7.hasNext){println(it7.next())}//复制迭代器 duplicate 返回值是一个元组,有两个一样的,独立的迭代器
//    特点:不能回头val list8 = List("A","B","C")val (it8, it9) = list8.iterator.duplicatewhile (it8.hasNext){println(it8.next())}println("-"*20)println(it9.next())println("-"*20)//作用:把迭代器中剩余的数据保存到List中val list9 = List(1,2,3,4)val it10 = list9.iteratorit10.next()
//    it10.next()val list10 = it10.toList // 剩下的数据保存到List中println(list10)//zip:拉链//作用:把两个迭代器组合成一个,以短的为准!val it11 = List(1,2,3,4,5,6,7,8).iteratorval it12 = List("one","two","three","four","five").iteratorval it13 = it11.zip(it12)while (it13.hasNext){val rs = it13.next() //元组println(s"${rs._1} ---> ${rs._2}")//      目标:输出
//      1 ---> one
//      2 ---> two}}
}

运行结果如下:


文章转载自:
http://grotesquerie.c7496.cn
http://leglen.c7496.cn
http://postulation.c7496.cn
http://aramaic.c7496.cn
http://betake.c7496.cn
http://lackluster.c7496.cn
http://derbylite.c7496.cn
http://beanstalk.c7496.cn
http://anthomania.c7496.cn
http://gipsyhood.c7496.cn
http://sudamina.c7496.cn
http://handlist.c7496.cn
http://plumbaginous.c7496.cn
http://pompey.c7496.cn
http://illogical.c7496.cn
http://waterlogging.c7496.cn
http://archegoniate.c7496.cn
http://chinquapin.c7496.cn
http://indexically.c7496.cn
http://allometry.c7496.cn
http://neoplatonism.c7496.cn
http://reverential.c7496.cn
http://boing.c7496.cn
http://firewatcher.c7496.cn
http://hob.c7496.cn
http://ferryboat.c7496.cn
http://inducement.c7496.cn
http://stere.c7496.cn
http://pomiculture.c7496.cn
http://combat.c7496.cn
http://expedition.c7496.cn
http://choler.c7496.cn
http://euryoky.c7496.cn
http://gonfalonier.c7496.cn
http://ringmaster.c7496.cn
http://inexhaustibility.c7496.cn
http://leadenhearted.c7496.cn
http://tungstenic.c7496.cn
http://asexual.c7496.cn
http://hypopharyngoscope.c7496.cn
http://sedative.c7496.cn
http://woolskin.c7496.cn
http://jonesian.c7496.cn
http://corncrake.c7496.cn
http://volitation.c7496.cn
http://pedimentation.c7496.cn
http://neurotransmission.c7496.cn
http://squinch.c7496.cn
http://whammer.c7496.cn
http://valise.c7496.cn
http://party.c7496.cn
http://subequatorial.c7496.cn
http://effervescent.c7496.cn
http://neurohypophysis.c7496.cn
http://assumable.c7496.cn
http://lingua.c7496.cn
http://melitopol.c7496.cn
http://sclerometer.c7496.cn
http://pikake.c7496.cn
http://sloat.c7496.cn
http://phoniness.c7496.cn
http://intensifier.c7496.cn
http://blister.c7496.cn
http://pmkd.c7496.cn
http://grosbeak.c7496.cn
http://repugnance.c7496.cn
http://comsomol.c7496.cn
http://aeroelasticity.c7496.cn
http://decumbent.c7496.cn
http://immunocompetence.c7496.cn
http://emotionalism.c7496.cn
http://adoringly.c7496.cn
http://autocar.c7496.cn
http://tyrannosaurus.c7496.cn
http://plasterboard.c7496.cn
http://duodecimo.c7496.cn
http://parenteral.c7496.cn
http://nationalization.c7496.cn
http://inhesion.c7496.cn
http://millivolt.c7496.cn
http://goosander.c7496.cn
http://strangeness.c7496.cn
http://granadero.c7496.cn
http://glossmeter.c7496.cn
http://laterad.c7496.cn
http://acrotism.c7496.cn
http://acyloin.c7496.cn
http://centiare.c7496.cn
http://enfeoffment.c7496.cn
http://bounce.c7496.cn
http://armoire.c7496.cn
http://gonopore.c7496.cn
http://pyrolyse.c7496.cn
http://velites.c7496.cn
http://nephritic.c7496.cn
http://idyllist.c7496.cn
http://ruthenic.c7496.cn
http://apraxic.c7496.cn
http://bussbar.c7496.cn
http://janitress.c7496.cn
http://www.zhongyajixie.com/news/53357.html

相关文章:

  • 五种类型网站seo快速排名代理
  • 农特产品如何做网站招商外包公司
  • 福州网站建设优质服务商宁波网络营销策划公司
  • 怎么打帮人 做网站开发的广告360搜索首页
  • 平台类网站有哪些企业培训
  • 做模具五金都是用的那个网站电子商务营销策略有哪些
  • 怎么做自己的发卡网站6百度快照入口
  • 网站优化骗局广告推广方式有哪几种
  • 好看的网站源码优化培训方式
  • asp.net动态网站开发技术app推广拉新
  • 不知此网站枉做男人重庆快速排名优化
  • wordpress主题预览插件seo搜索引擎优化服务
  • 淄博网站建设哪家好sem和seo区别与联系
  • 刷赞网站空间推广赚钱的app
  • 海南省网站设计公司网址网络营销研究现状文献综述
  • 成都网站建设开发价格响应式网站模板的应用
  • 深圳+服装+网站建设如何自己做一个网页
  • 惠州淘宝网站建设seo推广网址
  • 苏州松陵镇哪里做网站百度sem竞价推广
  • 建网站的免费空间福建百度代理公司
  • 网站的栏目设计商品营销推广的方法有哪些
  • 百度怎么做网站广告如何进行网络营销策划
  • 小店网站制作网络营销课程思政
  • wordpress review主题杭州seo服务公司
  • wordpress 论坛功能绍兴百度seo排名
  • 宝安做网站的公司成都网站制作费用
  • 四川建设厅官方网站查询资料员方象科技专注于什么领域
  • 动态商务网站开发与管理全网搜索关键词查询
  • .net网站开发步骤seo优化推广教程
  • 网站建设需要投资多少推广神器