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

commonMain.it.unibo.tuprolog.collections.AbstractClauseCollection.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: 0.17.4
Show newest version
package it.unibo.tuprolog.collections

import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils

internal abstract class AbstractClauseCollection>
protected constructor(protected val rete: ReteTree) : ClauseCollection {

    override val size: Int
        get() = rete.clauses.count()

    override fun isEmpty(): Boolean =
        size == 0

    override fun contains(element: Clause): Boolean =
        rete.get(element).any()

    override fun containsAll(elements: Iterable): Boolean =
        elements.all { it in this }

    abstract override fun add(clause: Clause): Self

    abstract override fun addAll(clauses: Iterable): Self

    abstract override fun retrieve(clause: Clause): RetrieveResult

    abstract override fun retrieveAll(clause: Clause): RetrieveResult

    override fun iterator(): Iterator =
        rete.clauses.iterator()

    override fun toString(): String {
        return "${this::class.simpleName}(${this.joinToString(", ")})"
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy