public boolean add(int e) { if (size >= vals.length) { expand(); } vals[size++] = e; return true; }
public boolean addAll(IntList c) { while (size + c.size >= vals.length) { expand(); } System.arraycopy(c.vals, 0, vals, size, c.size); size += c.size; return true; }
public boolean addAll(int index, IntList c) { if (index == size) { return addAll(c); } else if (index < size) { while (size + c.size >= vals.length) { expand(); } System.arraycopy(vals, index, vals, index + c.size, size - index); System.arraycopy(c.vals, 0, vals, index, c.size); size += c.size; return true; } else { throw new UnsupportedOperationException("Inserting list after end of this list"); } }