commonMain.it.unibo.tuprolog.collections.impl.MutableReteClauseMultiSet.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of theory-metadata Show documentation
Show all versions of theory-metadata Show documentation
In-memory storage and indexing facilities for ordered and unordered knowledge bases composed by logic clauses
package it.unibo.tuprolog.collections.impl
import it.unibo.tuprolog.collections.*
import it.unibo.tuprolog.collections.AbstractMutableReteClauseCollection
import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils
internal class MutableReteClauseMultiSet private constructor(
rete: ReteTree
) : MutableClauseMultiSet, AbstractMutableReteClauseCollection(rete) {
init {
require(!rete.isOrdered)
}
/** Construct a [MutableReteClauseMultiSet] from given clauses */
constructor(clauses: Iterable) : this(ReteTree.unordered(clauses)) {
TheoryUtils.checkClausesCorrect(clauses)
}
override fun count(clause: Clause): Long =
rete.get(clause).count().toLong()
override fun get(clause: Clause): Sequence =
rete.get(clause)
override fun equals(other: Any?): Boolean {
return if (other is MutableClauseMultiSet) {
MutableClauseMultiSet.equals(this, other)
} else {
false
}
}
override fun hashCode(): Int {
return MutableClauseMultiSet.hashCode(this)
}
}