All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.collections.rete.custom.AbstractReteNode.kt Maven / Gradle / Ivy

Go to download

In-memory storage and indexing facilities for ordered and unordered knowledge bases composed by logic clauses

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.collections.rete.custom

import it.unibo.tuprolog.collections.rete.custom.clause.IndexedClause
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.unify.Unificator

internal abstract class AbstractReteNode(override val unificator: Unificator) : ReteNode {
    fun  removeAllLazily(
        source: MutableList,
        clause: Clause,
    ): Sequence =
        sequence {
            val iter = source.iterator()
            while (iter.hasNext()) {
                val it = iter.next()
                if (unificator.match(it.innerClause, clause)) {
                    it.invalidateAllCaches()
                    iter.remove()
                    yield(it)
                }
            }
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy