Package gnu.trove.list

Examples of gnu.trove.list.TIntList


        sort(0, size);
    }

    /** {@inheritDoc} */
    public void sort(int fromIndex, int toIndex) {
        TIntList tmp = subList(fromIndex, toIndex);
        int[] vals = tmp.toArray();
        Arrays.sort(vals);
        set(fromIndex, vals);
    }
View Full Code Here


        };
    }

    /** {@inheritDoc} */
    public TIntList grep(TIntProcedure condition) {
        TIntList ret = new TIntLinkedList();
        for (TIntLink l = head; got(l); l = l.getNext()) {
            if (condition.execute(l.getValue()))
                ret.add(l.getValue());
        }
        return ret;
    }
View Full Code Here

        return ret;
    }

    /** {@inheritDoc} */
    public TIntList inverseGrep(TIntProcedure condition) {
        TIntList ret = new TIntLinkedList();
        for (TIntLink l = head; got(l); l = l.getNext()) {
            if (!condition.execute(l.getValue()))
                ret.add(l.getValue());
        }
        return ret;
    }
View Full Code Here

    public void propagate(int idxVarInProp, int mask) throws ContradictionException {
        hasChanged.clear();
        hasChanged.addLast(vars[idxVarInProp]);
        while (!hasChanged.isEmpty()) {
            IntVar var = hasChanged.pollFirst();
            TIntList nogoods = vars2nogood.get(var.getId());
            TIntList indices = vars2idxinng.get(var.getId());
            for (int i = 0; i < nogoods.size(); i++) {
                INogood ng = allnogoods.get(nogoods.get(i));
                int idx = ng.awakeOnInst(indices.get(i), this);
                if (idx > -1) {
                    hasChanged.addLast(ng.getVar(idx));
                } else if (idx == -99) { // a call to unwatch has been done!
                    i--;
                } else {
View Full Code Here

        e.add(this);
        if (d != null && d.getmType() == Deduction.Type.ValRem) {
            ValueRemoval vr = (ValueRemoval) d;
            IntVar var = (IntVar) vr.getVar();
            int val = vr.getVal();
            TIntList nogoods = vars2nogood.get(var.getId());
            TIntList indices = vars2idxinng.get(var.getId());
            for (int i = 0; i < nogoods.size(); i++) {
                INogood ng = allnogoods.get(nogoods.get(i));
                int idx = indices.get(i);
                if (val == ng.getVal(idx)) {
                    for (int j = 0; j < ng.size(); j++) {
                        if (ng.getVar(j) != var) {
//                            ng.getVar(j).explain(VariableState.REM, ng.getVal(j), e);
                            ng.getVar(j).explain(VariableState.DOM, e);
View Full Code Here

        if (idx > -1) {
            hasChanged.addLast(ng.getVar(idx));
        }
        while (!hasChanged.isEmpty()) {
            IntVar var = hasChanged.pollFirst();
            TIntList nogoods = vars2nogood.get(var.getId());
            TIntList indices = vars2idxinng.get(var.getId());
            for (int i = 0; i < nogoods.size(); i++) {
                ng = allnogoods.get(nogoods.get(i));
                idx = ng.awakeOnInst(indices.get(i), this);
                if (idx > -1) {
                    hasChanged.addLast(ng.getVar(idx));
                } else {
                    assert ng.isEntailed() != ESat.FALSE;
                }
View Full Code Here

            }
        }
    }

    public void watch(IntVar var, Nogood ng, int idxInNG) {
        TIntList nogoods = vars2nogood.get(var.getId());
        if (nogoods == null) {
            nogoods = new TIntArrayList();
            vars2nogood.put(var.getId(), nogoods);
        }
        nogoods.add(ng.getIdx());
        TIntList indices = vars2idxinng.get(var.getId());
        if (indices == null) {
            indices = new TIntArrayList();
            vars2idxinng.put(var.getId(), indices);
        }
        indices.add(idxInNG);
    }
View Full Code Here

        }
        indices.add(idxInNG);
    }

    public void unwatch(IntVar var, Nogood ng) {
        TIntList nogoods = vars2nogood.get(var.getId());
        if (nogoods != null) {
            int ni = nogoods.indexOf(ng.getIdx());
            if (ni > -1) {
                nogoods.removeAt(ni);
                TIntList indices = vars2idxinng.get(var.getId());
                indices.removeAt(ni);
            }
        }
    }
View Full Code Here

                    BoolVar bv = (BoolVar) clause;
                    ret &= addTrue(bv);
                } else {
                    LogOp n = (LogOp) clause;
                    BoolVar[] bvars = n.flattenBoolVar();
                    TIntList lits = new TIntArrayList(bvars.length);
                    for (int j = 0; j < bvars.length; j++) {
                        lits.add(sat.Literal(bvars[j]));
                    }
                    ret &= sat.addClause(lits);
                }
            }
            return ret;
View Full Code Here

     * @return true if the clause has been added to the clause store
     */
    public static boolean addClauses(BoolVar[] POSLITS, BoolVar[] NEGLITS) {
        Solver solver = POSLITS.length > 0 ? POSLITS[0].getSolver() : NEGLITS[0].getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        TIntList lits = new TIntArrayList(POSLITS.length + NEGLITS.length);
        for (int i = 0; i < POSLITS.length; i++) {
            lits.add(sat.Literal(POSLITS[i]));
        }
        for (int i = 0; i < NEGLITS.length; i++) {
            lits.add(SatSolver.negated(sat.Literal(NEGLITS[i])));
        }
        sat.addClause(lits);
        return true;
    }
View Full Code Here

TOP

Related Classes of gnu.trove.list.TIntList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.