aşağıdaki sözdizimi olduğu gibi the documentation for ArrayList#remove(int)
bakınız:
İşte
list.remove(list.size() - 1)
nasıl uygulandığı olduğunu. elementData
destek dizisinde bir arama yapar (böylece diziden kesebilir), bu sabit zaman olmalıdır (JVM bir nesne referansının boyutunu ve ofseti hesaplayabilen girişlerin sayısını bilir) ve numMoved
Bu durum için 0
geçerli:
public E remove(int index) {
rangeCheck(index); // throws an exception if out of bounds
modCount++; // each time a structural change happens
// used for ConcurrentModificationExceptions
E oldValue = elementData(index);
int numMoved = size - index - 1;
if (numMoved > 0)
System.arraycopy(elementData, index+1, elementData, index,
numMoved);
elementData[--size] = null; // Let gc do its work
return oldValue;
}
da 'Orada kaldırın (int)' ... –
'list.remove (list.size() - 1)' !!! – NINCOMPOOP
Yığın burada daha iyi bir çözüm olabilir mi? –