countediterator.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 32 行
SCALA
32 行
/* __ *\** ________ ___ / / ___ Scala API **** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */// $Id: CountedIterator.scala 14416 2008-03-19 01:17:25Z mihaylov $package scala/** Counted iterators keep track of the number of elements seen so far * * @author Martin Odersky * @version 1.0, 16/07/2003 */trait CountedIterator[+A] extends Iterator[A] { /** counts the elements in this iterator; counts start at 0 */ def count: Int override def counted : this.type = this override def buffered: BufferedIterator[A] with CountedIterator[A] = new BufferedIterator.Default[A] with CountedIterator[A] { protected def fill(sz : Int) = if (CountedIterator.this.hasNext) (CountedIterator.this.next) :: Nil else Nil override def count = CountedIterator.this.count - peekList(0).length override def counted : this.type = this override def buffered : this.type = this }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?