我有HashBasedTable Table<String, String, Double> employeeYearsOfService
AT&T={Bill Smith=2.0, Stacy Lerner=1.4},
fatima={Bill Smith=1.0, Stacy Lerner=2.0}
我的HashMap<String, Double> hm1
具有相同的keyRows employeeYearsOfService
AT&T=0.9628,
fatima=0.975
我想做这个计算
result= 2.0*0968+1.0*0.975| for column bill Smith
result= 1.4*0968+2.0*0.975| for column Stacy Lerner
并将结果存入新的hashmap hm4
//my table guava
Table <String,String,Double> employeeYearsOfService = HashBasedTable.create();
employeeYearsOfService.put("AT&T", "Stacy Lerner", 1.4);
employeeYearsOfService.put("AT&T", "Bill Smith", 2.0);
employeeYearsOfService.put("fatima", "Bill Smith", 1.0);
employeeYearsOfService.put("fatima", "Stacy Lerner", 2.0);
System.out.println("la matrice des notes");
System.out.println(employeeYearsOfService);
//my hashmap
HashMap <String,Double> hm1 = new HashMap <String,Double>();
hm1.put(AT & T, 0.962);
hm1.put(fatima, 0.975);
System.out.println(hm1);
我的calul循环
Double res = 0.0;
for (String ke : employeeYearsOfService.columnKeySet()) {
for (Entry<String, Double> employeek :
employeeYearsOfService.column(ke).entrySet()) {
for (Double mapValue : hm1.values()) {
res+ = employeek.getValue() *mapValue.doubleValue();
}
hm4.put(ke, res);
}
}
但问题是它没有计算我想要的东西
result= (2.0*0968+2.0*0.975)+(1.0*0968+1.0*0.975)| for column bill Smith
谢谢