private void resize(int newCapacity){
E[] newData = (E[])new Comparable[newCapacity];
for(int i = 1; i < size+1; i ++)
newData[i] = data[i];
data = newData;
capacity = newCapacity;
}
构建堆等高级数据结构时,底层的数组使用resize()实现动态数组
最新推荐文章于 2024-10-19 11:23:56 发布