public abstract class Table {
	
	private int cursor;
	private int N;
	private int[] array;
	
	public Table(){
		this.cursor = 0;
		this.N = 1;
		this.array = new int[this.N];
	}
	
	public int get(int i){
		if (i<this.cursor) return this.array[i];
		else throw new IndexOutOfBoundsException();
	}
	
	public void set(int i, int k){
		if (i<this.cursor) this.array[i] = k;
	}
	
	public void clear(){
		this.cursor = 0;
		this.N = 1;
		this.array = new int[this.N];			
	}
	
	public void add(int k){
		if (this.cursor==this.N){
			this.N = this.extendTo(this.N);
			int[] a = new int[this.N];
			for (int i=0;i<this.cursor;i++){
				a[i] = this.array[i];
			}
			this.array = a;
		}
		this.array[this.cursor] = k;
		this.cursor++;
	}
	
	public int capacity(){
		return this.N;
	}

	public abstract int extendTo(int i);
}