DOWNLOAD
~param bigtype~param type~make IntVector.java,Int,int~make DoubleVector.java,Double,double~make FloatVector.java,Float,floatpackage Utils; public class <bigtype>Vector { public <type>[] buf; public int size; public <bigtype>Vector(int initialCap) { this.buf = new <type>[initialCap]; this.size = 0; } public <bigtype>Vector() { this(8); } public int resize(int newSize) { int oldSize = size; int oldCap = buf != null ? buf.length : 0; int newCap = Math.max(oldCap, 8); while (newSize > newCap) newCap = (int)((float)newCap * 1.7f) + 1; if (newCap > oldCap) { <type>[] newBuf = new <type>[newCap]; if (buf != null && oldCap > 0) System.arraycopy(buf, 0, newBuf, 0, oldCap); buf = newBuf; } size = newSize; return oldSize; } public int add(<type> v) { resize(size + 1); buf[size-1] = v; return size-1; } public int add(<type>[] data) { return add(data, 0, data.length); } public int add(<type>[] data, int off, int len) { if (off >= 0 && len > 0 && off+len <= data.length) { resize(this.size + len); System.arraycopy(data, off, this.buf, this.size-len, len); } return this.size - len; } public int addFromSelf(int off, int len) { if (off >= 0 && len > 0 && off+len <= this.size) { resize(this.size + len); System.arraycopy(this.buf, off, this.buf, this.size-len, len); } return this.size - len; } public int addTwo(<type> a, <type> b) { resize(size + 2); buf[size-2] = a; buf[size-1] = b; return size-2; } public int addThree(<type> a, <type> b, <type> c) { resize(size + 3); buf[size-3] = a; buf[size-2] = b; buf[size-1] = c; return size-3; } public int addFour(<type> a, <type> b, <type> c, <type> d) { resize(size + 4); buf[size-4] = a; buf[size-3] = b; buf[size-2] = c; buf[size-1] = d; return size-4; } public <type> popOr(int defaultValue) { return size > 0 ? buf[--size] : defaultValue; } public <type> lastOr(int defaultValue) { return size > 0 ? buf[size-1] : defaultValue; } public <type>[] copy() { <type>[] array = new <type>[size]; if (size > 0) System.arraycopy(this.buf, 0, array, 0, size); return array; }}