Question: Code: import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.NoSuchElementException; public class UArrayList extends AArrayList implements UnorderedListADT { // Append element to list (at the end) // allocate

 Code: import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.NoSuchElementException; public class UArrayList extends

Code:

import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.NoSuchElementException;

public class UArrayList extends AArrayList implements UnorderedListADT {

// Append element to list (at the end) // allocate larger array when list is full @Override public boolean add(T element) { if (isFull()) // list is full growList();

listArray[listSize++] = element; modifiedCount++; return true; }

// Add element to front of the list // allocate larger array when list is full @Override public void addToFront(T element) { // TODO Auto-generated method stub

}

// Add element after an existing element in the list // Throw NoSuchElementException if existingElement is not found in the list @Override public void addAfter(T existingElement, T element) throws NoSuchElementException {

}

// Add element at specified index location // Throw IndexOutOfBoundsException if index is invalid public void addAt(int index, T element) throws IndexOutOfBoundsException { // TODO Auto-generated method stub

}

}

ListADT Code:

import java.util.NoSuchElementException;

public interface ListADT extends Iterable { public void clear();

// Append "it" at the end of the list for unordered lists // Add at appropriate position for ordered lists // The list must ensure that the list's capacity is not exceeded public boolean add(T it);

// Remove and return the current element public T remove(T element) throws NoSuchElementException;

// Remove and return the first element public T removeFirst() throws NoSuchElementException;

// Remove and return the last element public T removeLast() throws NoSuchElementException;

// Return the number of elements in the list public int size();

// Tell if the list is empty or not public boolean isEmpty();

// Return the first element in the list public T first();

// Return the last element in the list public T last();

// Tell if the element exists in the list public boolean contains(T element);

// Return the index of the specified element public int indexOf(T element);

// Copies the elements of the list onto the parameter array public void toArray(T[] anArray);

/* * Unused methods below * * // Insert "it" at the current location // The list must ensure that the * list's capacity is not exceeded public boolean addAtCurrent(T it); * * // Remove and return the current element public T removeCurrent() throws * NoSuchElementException; * * // Return the position of the current element public int currPos(); * * // Set the current position to "pos" public boolean moveToPos(int pos); * * // Return true if current position is at end of the list public boolean * isAtEnd(); * * // Return the current element public T getCurrentValue() throws * NoSuchElementException; * * // Set the current position to the start of the list public void * moveToStart(); * * // Set the current position to the end of the list public void moveToEnd(); * * // Move the current position one step left, no change if already at * beginning public void prev(); * * // Move the current position one step right, no change if already at end * public void next(); * * End of unused methods */

}

1. 2. + addToFront(T element) - add element at the front of the list, existing elements should shift + addAfter(T existingElement, T element) - add new element after an existing element, all elements after the element should be shifted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!