Skip to content

Commit

Permalink
Replace for loop by while
Browse files Browse the repository at this point in the history
  • Loading branch information
scorebot committed Nov 12, 2024
1 parent b5718da commit f30beb3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/scala/org/pmml4s/model/RuleSetModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ class RuleSet(val ruleSelectionMethods: Array[RuleSelectionMethod],
val defaultConfidence: Option[Double]) extends PmmlElement {

def first(series: Series): Option[SimpleRule] = {
for (rule <- rules) {
val len = rules.length
var i = 0
while (i < len) {
val rule = rules(i)
val res = rule.first(series)
if (res.isDefined)
return res
i += 1
}
None
}
Expand Down Expand Up @@ -245,10 +249,14 @@ class CompoundRule(val predicate: Predicate, val rules: Array[Rule]) extends Rul
} else Rule.emptySimpleRuleArray

override def first(series: Series): Option[SimpleRule] = if (predicate.eval(series) == Predication.TRUE) {
for (rule <- rules) {
val len = rules.length
var i = 0
while (i < len) {
val rule = rules(i)
val res = rule.first(series)
if (res.isDefined)
return res
i += 1
}
None
} else None
Expand Down

0 comments on commit f30beb3

Please sign in to comment.