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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
You know the right answer?
Please make a Generic SortedArrayList that the data structure code will support instantiating a sort...
Questions
question
Mathematics, 22.12.2019 21:31
question
Mathematics, 22.12.2019 21:31
Questions on the website: 13722363