package MyCollections.List;

public class My_ArrayList <V> implements MyList<V> {

	private int size;
	private V[] arr;
	private int index;
	
	My_ArrayList(){
		size = 10;
		index = 0;
		arr = (V[]) new Object[size];
	}
	

	@Override
	public boolean add(V e) {
		if (index >= arr.length)
			erstell_neue_array();
		
		arr[index++] = e;
		return true;
	}
	public void erstell_neue_array() {
		size *= 2;
		V[] neuarr = (V[]) new Object[size];
		for (int i = 0; i < arr.length ; i++)
			neuarr[i] = arr[i];
		arr = neuarr;
		neuarr = null;
	}
	
	@Override
	public boolean add(int i, V element) {
		if (arr[i] == null) {
			arr[i] =element ;
			return true;
		}
			
		
		return false;
	}

	@Override
	public int get(int index) {
		return 0;
	}

	@Override
	public boolean set(int index, V element) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean remove(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean remove(int index) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean contains(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int indexOf(Object o) {
		// TODO Auto-generated method stub
		return 0;
	}


	@Override
	public void printAll() {
		int i = 0;
		System.out.print("[");
		while(arr[i] != null && i < arr.length) {
			System.out.println(arr[i] + " ");
			i++;
		}
		System.out.print("]");	
	}
}
