Java 类gnu.trove.map.hash.TLongDoubleHashMap 实例源码

项目:olca-modules    文件:ProductSystemLinks.java   
long queryId(String sql) throws SQLException {
    TLongDoubleHashMap vals = new TLongDoubleHashMap();
    NativeSql.on(destDb).query(sql, r -> {
        vals.put(r.getLong(1), r.getDouble(2));
        return true;
    });
    long exchangeId = -1;
    double delta = 0;
    for (long id : vals.keys()) {
        double dist = Math.abs(amount - vals.get(id));
        if (exchangeId == -1 || dist < delta) {
            exchangeId = id;
            delta = dist;
        }
    }
    return exchangeId;
}
项目:olca-modules    文件:AllocationIndex.java   
private double causal(LongPair provider, CalcExchange e) {
    if (exchangeFactors == null)
        return 1d;
    TLongDoubleHashMap map = exchangeFactors.get(provider);
    if (map == null)
        return 1d;
    return map.get(e.exchangeId); // default is 1.0
}
项目:olca-modules    文件:ConversionTable.java   
private void loadFactors(Connection con, String table,
        TLongDoubleHashMap map) throws Exception {
    Statement statement = con.createStatement();
    String query = "select id, conversion_factor from " + table;
    ResultSet set = statement.executeQuery(query);
    while (set.next()) {
        long id = set.getLong("id");
        double factor = set.getDouble("conversion_factor");
        map.put(id, factor);
    }
    statement.close();
    set.close();
}
项目:sem-tag    文件:ConceptVector.java   
/**
 * Constructs an empty ConceptVector.
 */
public ConceptVector() {
    vector = new TLongDoubleHashMap();
}