0
我有這個類:的Java迭代HashMap的2級
public class docInfo {
private int freq;
private HashMap<String, Double> m = new HashMap<String, Double>();
}
private Map<String, docInfo> m;
我要遍歷所有的文檔信息的雙重價值,並改變它:
docInfo documento;
for (Map.Entry<String, docInfo> entry : m.entrySet()) {
word = entry.getKey();
docs = entry.getValue(); // docs map
for (Map.Entry<String, Double> entry2 : docs.getM().entrySet()){
score = entry2.getValue();
temp = score;
double log = Math.log10(docs.getFreq());
double tfw = log+cons;
docs.changeScoreTo(entry2.getKey(), tfw);
//entry2.setValue(tfw);
}
}
它工作正常,問題是,運行時間太長,我認爲我的代碼不適合工作。任何幫助,將不勝感激,
每個'Map'中有多少項?這段代碼被調用了多少次? – MAK
docInfo hashMap的總數是27k,大部分主要的hashmap沒有超過20個對象 – recoInrelax