This commit is contained in:
Debucquoy
2023-09-20 15:18:20 +02:00
parent 00d0cdfaf3
commit 4fd7542f03
228 changed files with 351 additions and 12 deletions

View File

@ -0,0 +1,35 @@
import java.util.Arrays;
public abstract class MyArrayList<T> {
protected T T1[], temp[];
protected int size;
public int size(){
return size;
}
public int physicalSize(){
return T1.length + temp.length + size * Integer.SIZE;
}
public T get(int i){
return T1[i];
}
public void add(T o){
makeSpaceIfNeeded();
T1[size++] = o;
}
public void add(int i, T o){
makeSpaceIfNeeded();
temp = Arrays.copyOfRange(T1, i, size-1);
T1[i] = o;
for(int j = 1; j <= temp.length; j++){
T1[j + i] = temp[i];
}
size++;
}
abstract void makeSpaceIfNeeded();
}