// 從數(shù)組中刪除index位置的元素, 返回刪除的元素
public int remove(int index){
if(index < 0 || index >= size)
throw new IllegalArgumentException("Remove failed. Index is illegal.");
int ret = data[index];
for(int i = index + 1 ; i < size ; i ++)
data[i - 1] = data[i];
size --;
return ret;
}
// 從數(shù)組中刪除第一個元素, 返回刪除的元素
public int removeFirst(){
return remove(0);
}
// 從數(shù)組中刪除最后一個元素, 返回刪除的元素
public int removeLast(){
return remove(size - 1);
}