0
我正在尋找覆蓋/替換數組列表中的值的方法,數組列表本身是散列表中的值。如何替換本身是散列圖值的數組列表中的值
這是我們提供的一些代碼。
public Equations(Double[][] matrix) {
// save input matrix into M -- it represents the equations
M = new HashMap<Integer,ArrayList<Double>>();
for (int i=0;i<matrix.length;i++) { // step through rows of matrix
ArrayList<Double> L = new ArrayList<Double>(Arrays.asList(matrix[i]));
M.put(i,L);
}
}
// handy method to return a specific coefficient in row/column
public Double Element(int row, int column) {
return M.get(row).get(column);
}
我們使用Hashmaps來執行高斯消除。我準備了我的Gaussian Elimination代碼,用於查找該行的因子,將其應用於該行的第一列值,然後從該行之前的值中減去該值。得到的數字是我需要傳遞給hashmap和arraylist來替換剛剛被分解和減去的值。
有沒有辦法讓我用數字替換這個數字?或者我需要構建一個全新的數組列表,並使用M.put(key,arraylist)替換舊的數組列表?
只需將其替換爲通常情況即可。除非數組列表是關鍵字,否則散列表是不相關的。 – EJP