Search in sources :

Example 1 with TIntDoubleProcedure

use of gnu.trove.procedure.TIntDoubleProcedure in project ProPPR by TeamCohen.

the class RedBlueGraph method colorPart.

public TIntDoubleMap colorPart(final Set<String> color, TIntDoubleMap vec) {
    final TIntDoubleMap result = new TIntDoubleHashMap();
    vec.forEachEntry(new TIntDoubleProcedure() {

        @Override
        public boolean execute(int k, double v) {
            if (color.contains(nodes.getSymbol(k)))
                result.put(k, v);
            return true;
        }
    });
    return result;
}
Also used : TIntDoubleHashMap(gnu.trove.map.hash.TIntDoubleHashMap) TIntDoubleMap(gnu.trove.map.TIntDoubleMap) TIntDoubleProcedure(gnu.trove.procedure.TIntDoubleProcedure)

Example 2 with TIntDoubleProcedure

use of gnu.trove.procedure.TIntDoubleProcedure in project ProPPR by TeamCohen.

the class LightweightStateGraph method getFeatures.

public Map<Feature, Double> getFeatures(State u, State v) {
    int ui = this.nodeTab.getId(u), vi = this.nodeTab.getId(v);
    if (!edgeFeatureDict.containsKey(ui))
        return DEFAULT_FD;
    TIntObjectHashMap<TIntDoubleHashMap> fu = edgeFeatureDict.get(ui);
    if (!fu.containsKey(vi))
        return DEFAULT_FD;
    TIntDoubleHashMap fuvi = fu.get(vi);
    final HashMap<Feature, Double> ret = new HashMap<Feature, Double>();
    fuvi.forEachEntry(new TIntDoubleProcedure() {

        @Override
        public boolean execute(int fi, double wt) {
            ret.put(featureTab.getSymbol(fi), wt);
            return true;
        }
    });
    return ret;
}
Also used : TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) HashMap(java.util.HashMap) TIntDoubleHashMap(gnu.trove.map.hash.TIntDoubleHashMap) TIntDoubleHashMap(gnu.trove.map.hash.TIntDoubleHashMap) TIntDoubleProcedure(gnu.trove.procedure.TIntDoubleProcedure) Feature(edu.cmu.ml.proppr.prove.wam.Feature)

Aggregations

TIntDoubleHashMap (gnu.trove.map.hash.TIntDoubleHashMap)2 TIntDoubleProcedure (gnu.trove.procedure.TIntDoubleProcedure)2 Feature (edu.cmu.ml.proppr.prove.wam.Feature)1 TIntDoubleMap (gnu.trove.map.TIntDoubleMap)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 HashMap (java.util.HashMap)1