clear
是CostTable
类中的一个方法,该方法用于清空成本表中所有的数据。
CostTable.clear();
该方法不接受任何参数。
该方法不返回任何值。
var ct = new CostTable();
ct.set(0, 0, 10);
ct.set(1, 1, 20);
console.log(ct.get(0, 0)); //输出:10
console.log(ct.get(1, 1)); //输出:20
ct.clear();
console.log(ct.get(0, 0)); //输出:undefined
console.log(ct.get(1, 1)); //输出:undefined
使用该方法会清空整个成本表中的数据,使用前请确保已保存所需数据。