Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

Describe the role of HR in succession management.

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago