/** for (int i = size; i >

/** * Your implementation of an ArrayList. * * @author Peiyu Wang * @version 1 */public class ArrayList implements ArrayListInterface {
// Do not add new instance variables. private T backingArray; private int size;
/** * Constructs a new ArrayList. * * You may add statements to this method. */ public ArrayList() { backingArray = (T) new ObjectINITIAL_CAPACITY; size = 0; }
@Override public void addAtIndex(int index, T data) { if (data == null) { throw new IllegalArgumentException(“Error,data is null”); }
if (index < 0 || index > size) { throw new IndexOutOfBoundsException(“Error, index is negative” + “or larger than Array size”); }
if (size >= backingArray.length) { T temp = (T) new Object2 * backingArray.length; for (int i = 0; i < backingArray.length; i++) { tempi = backingArrayi; } backingArray = temp; } for (int i = size; i > index; i–) { backingArrayi = backingArrayi – 1; } backingArrayindex = data; size = size + 1;

}
@Override public void addToFront(T data) { if (data == null) { throw new IllegalArgumentException(“Error,data is null”); } if (size >= backingArray.length) { T temp = (T) new Object2 * backingArray.length; for (int i = 0; i < backingArray.length; i++) { tempi = backingArrayi; } backingArray = temp; } for (int i = size; i > 0; i–) { backingArrayi = backingArrayi – 1; } size = size + 1; backingArray0 = data;

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

}
@Override public void addToBack(T data) { if (data == null) { throw new IllegalArgumentException(“Error,data is null”); } if (size >= backingArray.length) { T temp = (T) new Object2 * backingArray.length; for (int i = 0; i < backingArray.length; i++) { tempi = backingArrayi; } backingArray = temp; } backingArraysize = data; size = size + 1; } @Override public T removeAtIndex(int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(“Error, index is” + ” negative or larger than Array size”); } if (size == 0) { return null; }
T temp = backingArrayindex;
for (int i = index; i < size - 1; i++) { backingArrayi = backingArrayi + 1; } backingArraysize - 1 = null; size--; return temp; } @Override public T removeFromFront() { if (size == 0) { return null; } T temp = backingArray0; for (int i = 0; i < size - 1; i++) { backingArrayi = backingArrayi + 1; } backingArraysize - 1 = null; size--; return temp; } @Override public T removeFromBack() { if (size == 0) { return null; } T temp = backingArraysize - 1; backingArraysize - 1 = null; size--; return temp; } @Override public T get(int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(“Error, index is negative ” + “or larger than Array size”); }
return backingArrayindex; }
@Override public boolean isEmpty() { return size == 0; }
@Override public int size() { return size; }
@Override public void clear() { backingArray = (T) new ObjectINITIAL_CAPACITY; size = 0; }
@Override public Object getBackingArray() { // DO NOT MODIFY. return backingArray; }}

x

Hi!
I'm Barry!

Would you like to get a custom essay? How about receiving a customized one?

Check it out