Package gnu.trove.set.hash

Examples of gnu.trove.set.hash.TIntHashSet


    }

    public FiniteAutomaton intersection(IAutomaton otherI) {
        FiniteAutomaton other = (FiniteAutomaton) otherI;
        Automaton inter = this.representedBy.intersection(other.representedBy);
        TIntHashSet alphabet = new TIntHashSet();
        for (int a : this.alphabet.toArray()) {
            if (other.alphabet.contains(a))
                alphabet.add(a);
        }
        return new FiniteAutomaton(inter, alphabet);
    }
View Full Code Here



    public FiniteAutomaton concatenate(FiniteAutomaton otherI) {
        FiniteAutomaton other = (FiniteAutomaton) otherI;
        Automaton conc = this.representedBy.concatenate(other.representedBy);
        TIntHashSet alphabet = new TIntHashSet(this.alphabet.toArray());
        alphabet.addAll(other.alphabet.toArray());
        return new FiniteAutomaton(conc, alphabet);
    }
View Full Code Here

    public void setDeterministic(boolean deterministic) {
        this.representedBy.setDeterministic(deterministic);
    }

    public TIntHashSet getFinalStates() {
        TIntHashSet finals = new TIntHashSet();
        for (int i = 0; i < states.size(); i++) {
            if (states.get(i).isAccept())
                finals.add(i);
        }
        return finals;
    }
View Full Code Here

        return transitions;
    }

    public ArrayList<int[]> _removeSymbolFromAutomaton(int alpha) {
        char c = getCharFromInt(alpha);
        TIntHashSet setOfRemoved = new TIntHashSet();
        ArrayList<Triple> triples = new ArrayList<Triple>();
        for (int i = 0; i < states.size(); i++) {
            State s = states.get(i);
            for (Transition t : s.getTransitions()) {

                if (t.getMin() <= c && t.getMax() >= c) {
                    triples.add(new Triple(i, stateToIndex.get(t.getDest()), alpha));
                    setOfRemoved.add(i);
                }
            }
            for (Triple t : triples) {
                this.deleteTransition(t.a, t.b, t.c);
            }
            triples.clear();

        }
        alphabet.remove(alpha);
        // this.removeDeadTransitions();
        ArrayList<int[]> couple = new ArrayList<int[]>();
        for (int i = 0; i < states.size(); i++) {
            State s = states.get(i);
            for (Transition t : s.getTransitions()) {
                int dest = stateToIndex.get(t.getDest());
                if (setOfRemoved.contains(dest)) {
                    for (char d = t.getMin(); d <= t.getMax(); d++)
                        couple.add(new int[]{i, getIntFromChar(d)});
                }

            }
View Full Code Here

    public FiniteAutomaton clone() throws CloneNotSupportedException {
        FiniteAutomaton auto = (FiniteAutomaton) super.clone();
        auto.representedBy = new Automaton();
        auto.states = new ArrayList<State>();
        auto.stateToIndex = new TObjectIntHashMap<State>();
        auto.alphabet = new TIntHashSet();
        auto.nbStates = this.nbStates;
        for (int i = 0; i < this.nbStates; i++) {
            State s = new State();
            auto.states.add(s);
            auto.stateToIndex.put(s, i);
View Full Code Here

    public void buildModel() {
        _dom = readDOM(dir + File.separator + DOM);
        _var = readVAR(dir + File.separator + VAR);
        _ctr = readCTR(dir + File.separator + CTR);

        TIntHashSet values = new TIntHashSet();

        vars = new IntVar[_var.length];

        vars = new IntVar[_var[_var.length - 1][0]];
        int n = vars.length;
        int prev = 0;
        for (int i = 0; i < _var.length; i++) {
            int vidx = _var[i][0] - 1;
            if (vidx > prev) {
                for (; prev < vidx; ) {
                    vars[prev++] = VariableFactory.fixed(0, solver);
                }
            }
            int didx = _var[i][1];
            if (_var[i].length > 2) {
                vars[vidx] = VariableFactory.fixed(_var[i][2], solver);
            } else {
                vars[vidx] = VariableFactory.enumerated("v_" + vidx, _dom[didx], solver);
                values.addAll(_dom[didx]);
            }
            prev = vidx + 1;
        }
        int[][] graph = new int[n][n];

        for (int i = 0; i < _ctr.length; i++) {
            int[] ci = _ctr[i];
            solver.post(IntConstraintFactory.distance(vars[ci[0] - 1], vars[ci[1] - 1], (ci[2] == 0 ? "=" : ">"), ci[3]));

            // MARK BOTH SPOTS IN "PRECEDENCE" GRAPH
            graph[ci[0] - 1][ci[1] - 1] = 1;
            graph[ci[1] - 1][ci[0] - 1] = 1;

        }
        if (opt) {
            cards = VariableFactory.boundedArray("c", values.size(), 0, vars.length, solver);
            freqs = values.toArray();
            Arrays.sort(freqs);
            for (int i = 0; i < freqs.length; i++) {
                solver.post(IntConstraintFactory.count(freqs[i], vars, cards[i]));
            }
            nb0 = VariableFactory.bounded("nb0", 0, freqs.length, solver);
View Full Code Here

    /////////////////////

    protected int[][] readDOM(String filename) {
        FileReader f;
        String line;
        TIntHashSet values = new TIntHashSet();
        try {
            f = new FileReader(filename);
            BufferedReader r = new BufferedReader(f);
            List<int[]> domains = new ArrayList<int[]>();
            while ((line = r.readLine()) != null) {
                Scanner sc = new Scanner(line);
                sc.nextInt();
                while (sc.hasNextInt()) {
                    values.add(sc.nextInt());
                }
                domains.add(values.toArray());
                values.clear();
            }
            int[][] data = new int[domains.size()][];
            for (int i = 0; i < domains.size(); i++) {
                data[i] = domains.get(i);
                Arrays.sort(data[i]);
View Full Code Here

     */
    public void add(Propagator p) {
        if (Configuration.PROP_IN_EXP) {
            if (this.propagators == null) {
                this.propagators = new ArrayList<Propagator>(4);
                this.pid = new TIntHashSet(4);
            }
            if (this.pid.add(p.getId())) {
                this.propagators.add(p);
            }
        }
View Full Code Here

                }
            }

            if (this.deductions == null) {
                this.deductions = new ArrayList<Deduction>(4);
                this.did = new TIntHashSet();
            }
            if (this.did.add(d.id)) {
                this.deductions.add(d);
            }
        }
View Full Code Here

      GArcs.dests[a.id] = a.dest.id;
      GArcs.origs[a.id] = a.orig.id;

      int idx = starts[a.orig.layer] + a.value - offsets[a.orig.layer];
      if (sups[idx] == null)
        sups[idx] = new TIntHashSet();
      sups[idx].add(a.id);

    }

    for (int i = 0; i < sups.length; i++) {
View Full Code Here

TOP

Related Classes of gnu.trove.set.hash.TIntHashSet

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.