commonMain.it.unibo.tuprolog.bdd.impl.AnyVisitor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bdd-jvm Show documentation
Show all versions of bdd-jvm Show documentation
Multi-platform library for representing and manipulating Binary Decision Diagrams
package it.unibo.tuprolog.bdd.impl
import it.unibo.tuprolog.bdd.BinaryDecisionDiagram
import it.unibo.tuprolog.bdd.BinaryDecisionDiagramVisitor
/**
* Checks weather at least one node in a [BinaryDecisionDiagram] makes
* a certain predicate succeed.
*
* @author Jason Dellaluce
*/
internal class AnyVisitor>(
private val predicate: (T) -> Boolean
) : BinaryDecisionDiagramVisitor {
override fun visit(
node: BinaryDecisionDiagram.Terminal
): Boolean = false
override fun visit(node: BinaryDecisionDiagram.Variable): Boolean {
var result = predicate(node.value)
if (!result) {
result = node.low.accept(this)
}
if (!result) {
result = node.high.accept(this)
}
return result
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy