subject

Please make a Generic SortedArrayList that the data structure code will support instantiating a sorted array list of Characters, Integers, or Pokemon. will need to code the generic class with particular attention to detail, for they must make the contents of the structure Comparable. Not only will the data structure the students create support additional methods (e. g., size), but it will always keep its contents in their natural order. Thus, when someone adds the numbers 4, 7, and 1 to an empty SortedArrayList, it actually stores them as: 1, 4, 7. The smallest thing in the list is located at index position 0. The largest thing is at index position size()-1. The Comparable type guarantees that objects that implement the interface provide the compareTo() method. This method returns either a negative number, a positive number, or zero. The value it returns reflects the relation between the two objects. None of your solutions should actually implement a compareTo method. Instead, the Java solutions should use the method already on the objects it intends to store inside. In addition to maintaining sorted order at all times, this SortedArrayList automatically expands its capacity (not size) when it fills up. It also shrinks after it detects that it is mostly empty. When the driver attempts to add an item to the structure when its size is at capacity, rather than failing because there is insufficient room, the structure shall increase its capacity. To do so, it must allocate a new backing-array with the expanded capacity and then copy the contents of the old array into the new memory area. Students may use memcopy or System. arraycopy for this operation, or they may do so using a simple for loop. Required Public Methods:Constructors: The class must include a default constructor (zero arguments) and a constructor that accepts a single argument representing the initial capacity of the internal array. boolean add(E item)Inserts the item into the array. The sorted array increases the size of the structure by one and places the new item in its correct position. This may cause a shift in the array's existing contents as the data structure moves everything over to make room for the new item. int capacity()Returns the maximum possible number of items the data structure may store (the size of the fuel tank) at the backing-array's current size. void clear()Resets the data structure's size to zero. E get(int index)Returns, but does not remove, the value of the item stored at position index within the array. boolean isEmpty()Returns true if size() == 0 and false under all other conditions. E remove(int index)Returns the value of the item stored at position index in the array (assuming it is within bounds) and deletes the item from the array. This may cause the array contents to shift over to fill the hole left by the vacated item. int size()This method returns the number of items stored inside the data structure (how much fuel is in the tank).

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, lexhorton2002
The great length of north america causes the climate to be varied. true false
Answers: 2
image
Computers and Technology, 23.06.2019 04:20, RandomLollipop
Which network media uses different regions of the electromagnetic spectrum to transmit signals through air? uses different regions of the electromagnetic spectrum to transmit signals through air.
Answers: 2
image
Computers and Technology, 23.06.2019 14:00, LuvIsRage2
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
image
Computers and Technology, 24.06.2019 15:00, dummynate
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
Please make a Generic SortedArrayList that the data structure code will support instantiating a sort...

Questions in other subjects:

Konu
Mathematics, 11.03.2021 18:20
Konu
Mathematics, 11.03.2021 18:20