"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Clause = exports.Clause = void 0;
const JavaObject_1 = require("../../../java/lang/JavaObject");
const JavaInteger_1 = require("../../../java/lang/JavaInteger");
const AVLSet_1 = require("../../../core/adt/set/AVLSet");
const Variable_1 = require("../../../core/kursblockung/satsolver/Variable");
const NullPointerException_1 = require("../../../java/lang/NullPointerException");
class Clause extends JavaObject_1.JavaObject {
    variables;
    free = 0;
    sat = 0;
    /**
     * Implementation for method overloads of 'constructor'
     */
    constructor(__param0, __param1, __param2) {
        super();
        if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.core.kursblockung.satsolver.Variable')))) && (typeof __param1 === "undefined") && (typeof __param2 === "undefined")) {
            let pX = (0, Variable_1.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Variable)(__param0);
            this.variables = [pX];
            this.free = 1;
            this.sat = 0;
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.core.kursblockung.satsolver.Variable')))) && ((typeof __param1 !== "undefined") && ((__param1 instanceof JavaObject_1.JavaObject) && (__param1.isTranspiledInstanceOf('de.nrw.schule.svws.core.kursblockung.satsolver.Variable')))) && (typeof __param2 === "undefined")) {
            let pX = (0, Variable_1.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Variable)(__param0);
            let pY = (0, Variable_1.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Variable)(__param1);
            this.variables = [pX, pY];
            this.free = 2;
            this.sat = 0;
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.core.kursblockung.satsolver.Variable')))) && ((typeof __param1 !== "undefined") && ((__param1 instanceof JavaObject_1.JavaObject) && (__param1.isTranspiledInstanceOf('de.nrw.schule.svws.core.kursblockung.satsolver.Variable')))) && ((typeof __param2 !== "undefined") && ((__param2 instanceof JavaObject_1.JavaObject) && (__param2.isTranspiledInstanceOf('de.nrw.schule.svws.core.kursblockung.satsolver.Variable'))))) {
            let pX = (0, Variable_1.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Variable)(__param0);
            let pY = (0, Variable_1.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Variable)(__param1);
            let pZ = (0, Variable_1.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Variable)(__param2);
            this.variables = [pX, pY, pZ];
            this.free = 3;
            this.sat = 0;
        }
        else
            throw new Error('invalid method overload');
    }
    toString() {
        let s = "";
        for (let v of this.variables) {
            if (v.index === -1) {
                return "[SAT]";
            }
            if (v.index >= 0) {
                s = s.valueOf() + " " + v.nr;
            }
        }
        return "[" + s.valueOf() + "]";
    }
    getSet() {
        let set = new AVLSet_1.AVLSet();
        for (let v of this.variables) {
            if (v.index >= 0) {
                set.add(v.nr);
            }
        }
        return set;
    }
    compareTo(o) {
        let set1 = this.getSet();
        let set2 = o.getSet();
        if (set1.size() < set2.size())
            return -1;
        if (set1.size() > set2.size())
            return +1;
        let i1 = set1.iterator();
        let i2 = set2.iterator();
        if ((i1 === null) || (i2 === null))
            throw new NullPointerException_1.NullPointerException();
        while (i1.hasNext()) {
            let cmp = JavaInteger_1.JavaInteger.compare(i1.next().valueOf(), i2.next().valueOf());
            if (cmp !== 0)
                return cmp;
        }
        return 0;
    }
    isTranspiledInstanceOf(name) {
        return ['java.lang.Comparable', 'de.nrw.schule.svws.core.kursblockung.satsolver.Clause'].includes(name);
    }
}
exports.Clause = Clause;
function cast_de_nrw_schule_svws_core_kursblockung_satsolver_Clause(obj) {
    return obj;
}
exports.cast_de_nrw_schule_svws_core_kursblockung_satsolver_Clause = cast_de_nrw_schule_svws_core_kursblockung_satsolver_Clause;
//# sourceMappingURL=Clause.js.map