Skip to content

Commit

Permalink
最終的に配列が欲しいfor式では、Array.rangeを使用するように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
sile committed Mar 4, 2012
1 parent 4a96d24 commit 33ca57a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/net/reduls/scala/gomoku/Morpheme.scala
@@ -1,5 +1,5 @@
package net.reduls.scala.gomoku

final class Morpheme(val surface:String, val feature:String, val start:Int) {
case class Morpheme(val surface:String, val feature:String, val start:Int) {
override def toString: String = surface+"@"+feature
}
10 changes: 5 additions & 5 deletions src/net/reduls/scala/gomoku/dic/Char.scala
Expand Up @@ -7,18 +7,18 @@ object Char {

private val charCode =
withDictionayData("code-map.bin") {
(in, codeLimit) => {for(_ <- 1 to codeLimit) yield in.readChar}.toArray
(in, codeLimit) => for(_ <- Array.range(0, codeLimit)) yield in.readChar
}

private val (categories, compatibleMasks) =
withDictionayData("category.bin", "code.bin") {
(in1, charCategoryNum, in2, codeLimit) =>
val charCategories =
{for(i <- 0 until charCategoryNum)
yield new Category(i, in1.readByte==1, in1.readByte==1, in1.readByte)}.toArray
for(i <- Array.range(0, charCategoryNum))
yield new Category(i, in1.readByte==1, in1.readByte==1, in1.readByte)

val pair = {for(i <- 0 until codeLimit)
yield (charCategories(in2.readByte), in2.readShort)}.toArray.unzip
val pair = (for(i <- Array.range(0, codeLimit))
yield (charCategories(in2.readByte), in2.readShort)).unzip
(pair._1.toArray, pair._2.toArray)
}

Expand Down
7 changes: 3 additions & 4 deletions src/net/reduls/scala/gomoku/dic/Morpheme.scala
Expand Up @@ -8,10 +8,9 @@ object Morpheme {
private val surId_to_morps =
withDictionayData("id-morphemes-map.bin", "morpheme.bin") {
(in1, surfaceIdLimit, in2, morphemeCount) =>
{for(_ <- 1 to surfaceIdLimit; length = in1.readByte) yield
{for(_ <- 1 to length)
yield encodeInfo(in2.readShort, in2.readShort)}.toArray
}.toArray
for(_ <- Array.range(0, surfaceIdLimit); length = in1.readByte) yield
for(_ <- Array.range(0, length))
yield encodeInfo(in2.readShort, in2.readShort)
}

private def encodeInfo(posId:Short, cost:Short): MorphemeInfo =
Expand Down
2 changes: 1 addition & 1 deletion src/net/reduls/scala/gomoku/dic/SurfaceId.scala
Expand Up @@ -6,7 +6,7 @@ import net.reduls.scala.gomoku.util.Misc._
object SurfaceId {
private val nodes =
withDictionayData("surface-id.bin") {
(in, nodeCount) => {for(_ <- 1 to nodeCount) yield in.readLong}.toArray
(in, nodeCount) => for(_ <- Array.range(0, nodeCount)) yield in.readLong
}

private val idOffset =
Expand Down

0 comments on commit 33ca57a

Please sign in to comment.