Skip to content

Commit 07a4f6b

Browse files
committed
for loop to While loop
1 parent 0a6d8e9 commit 07a4f6b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
144144
parentImpurities: Array[Double],
145145
filters: Array[List[Filter]]): Unit = {
146146
// 0 corresponds to the left child node and 1 corresponds to the right child node.
147-
// TODO: Convert to while loop
148-
for (i <- 0 to 1) {
147+
var i = 0
148+
while (i <= 1) {
149149
// Calculate the index of the node from the node level and the index at the current level.
150150
val nodeIndex = scala.math.pow(2, level + 1).toInt - 1 + 2 * index + i
151151
if (level < maxDepth - 1) {
@@ -164,6 +164,7 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
164164
logDebug("Filter = " + filter)
165165
}
166166
}
167+
i += 1
167168
}
168169
}
169170
}

0 commit comments

Comments
 (0)