Computers and Technology

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).

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 17:00, harlon852
The length of time that a slide appears before automatically advancing to the next slide can be set in the timing group under the transitions tab. transition to this slide group under the transitions tab. timing group in the master slide view. transition to this slide group in the master slide view.
Answers: 1
image
Computers and Technology, 24.06.2019 17:30, mariahdelossantos031
Which computer network component connects two different networks together and allows them to communicate? a is a node (or a device) that connects two different networks together and allows them to communicate.
Answers: 2
image
Computers and Technology, 24.06.2019 19:20, boyancecristina
Which command suppresses the visibility of a particular row or column in a worksheet?
Answers: 1
image
Computers and Technology, 25.06.2019 01:30, 91miketaylor
The study of how to design software, solve problems such as computer security threats, or come up with better ways of handling data storage
Answers: 1
Do you know the correct answer?
Please make a Generic SortedArrayList that the data structure code will support instantiating a sort...

Questions in other subjects:

Konu
Spanish, 03.08.2019 07:00