package io.nub.core.util.arrays;

import java.util.ArrayList;

/**
 * @author Nektro
 *
 * @param <T>
 */
public class Array<T> extends ArrayList<T>
{
	private static final long serialVersionUID = -6223130567146190736L;
	
	public Array()
	{
		super();
	}
	
	public Array(int length)
	{
		super(length);
	}
	
	@SuppressWarnings("unchecked")
	public Array(T... array)
	{
		super();
		for (T o : array)
			this.add(o);
	}
	
	
	public boolean addAll(T[] c)
	{
		for (T t : c)
			this.add(t);
		return true;
	}
	
	public T lastIndex()
	{
		return this.get(size() - 1);
	}
	
	public Array<T> reverse()
	{
		Array<T> res = new Array<T>(this.size());
		for (int i = 0; i < this.size(); i++)
			res.add(this.get(this.size() - i - 1));
		return res;
	}
	
	public void pop()
	{
		this.remove(this.size()-1);
	}
	
	public void shift()
	{
		this.remove(0);
	}
}

@@ -141,16 +141,37 @@
 yList%3CT%3E
+ implements Cloneable
 %0A%7B%0A%09priv
@@ -216,27 +216,26 @@
  = -
-6223130567146190736
+588781360801958621
 L;%0A%09
@@ -434,16 +434,272 @@
 );%0A%09%7D%0A%09%0A
+%09@SuppressWarnings(%22unchecked%22)%0A%09@Override%0A%09public T%5B%5D toArray() %7B%0A%09%09T%5B%5D ta = (T%5B%5D) new Object%5Bsize()%5D;%0A%09%09for (int i = 0; i %3C size(); i++)%0A%09%09%09ta%5Bi%5D = get(i);%0A%09%09return ta;%0A%09%7D%0A%09%0A%09@Override%0A%09public Array%3CT%3E clone()%0A%09%7B%0A%09%09return new Array%3C%3E(this.toArray());%0A%09%7D%0A
 %09%0A%09publi
@@ -1116,10 +1116,347 @@
 (0);%0A%09%7D%0A
+%09%0A%09@Override%0A%09public T set(int index, T element)%0A%09%7B%0A%09%09int size = size();%0A%09%09if (index %3E= size)%0A%09%09%09for (int i = 0; i %3C index - size + 1; i++)%0A%09%09%09%09add(null);%0A%09%09return super.set(index, element);%0A%09%7D%0A%09%0A%09@Override%0A%09public T get(int index) %7B%0A%09%09try %7B%0A%09%09%09return super.get(index);%0A%09%09%7D%0A%09%09catch (IndexOutOfBoundsException e) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%7D%0A
 %7D%0A

add Cloneable to Array and overriden set and get methods