0
/** * 2Dマトリックス(コンストラクタの代わりに) *行と列の両方がゼロより大きくなければならを初期化します。 * @param cols行列の幅を指定する整数は、> 0である必要があります。 * @returnブール値。入力が受け入れ可能であればtrue、そうでなければfalse。 */2Dマトリックス
public boolean init(int rows, int cols)
{
matrix = new LinkedList<LinkedList<Integer>>();
if(this.rows < 0 || this.cols < 0)
return false;
if(this.rows > 0 && this.cols > 0)
for(int i = 0; i < rows; i++)
matrix.add(new LinkedList<Integer>());
for(int j = 0; j < cols; j++)
matrix.get(cols).add(j);
return true;
}
私は、リンクリストのリンクリストを使用して、この行列を初期化しようとしていますが、私はこだわっています。