chararrayposition.scala

来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 46 行

SCALA
46
字号
/*                     __                                               *\**     ________ ___   / /  ___     Scala API                            ****    / __/ __// _ | / /  / _ |    (c) 2006-2007, LAMP/EPFL             ****  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **** /____/\___/_/ |_/____/_/ | |                                         ****                          |/                                          **\*                                                                      */// $Id: CharArrayPosition.scala 14416 2008-03-19 01:17:25Z mihaylov $package scala.util.parsing.input/** <code>CharArrayPosition</code> implements the general <code>Position</code> *  class for documents represented by an <code>Array</code> of `char's. * *  @param source The contents of the document in which this position is contained *  @param line   The line number of the position (1-based) *  @param columm The column number of the position (1-based) * * @author Martin Odersky, Adriaan Moors  * @deprecated; use OffsetPosition instead */@deprecatedclass CharArrayPosition(val source: Array[Char], val line: Int, val column: Int) extends Position {  // TODO: this could be implemented more high-level:   // return the string representation of the sub-array of source that starts  // after the (lnum-1)'ed '\n' up to (but not including) the (lnum)'ed '\n'   protected def lineContents = {    var i = 0    var l = 1    while (i < source.length && l < line) {      while (i < source.length && source(i) != '\n') i += 1      i += 1      l += 1    }    var chars = new StringBuffer    while (i < source.length && source(i) != '\n') {      chars append source(i)      i += 1    }    chars.toString  }}    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?