OrderedStringListType Class
In this chapter we presented a class named StringListType, which holds a list of String objects. Now you are to write a class named OrderedStringListType. The class should hold a list of String objects, which are always sorted in ascending order. The class should support the operations described in Table.
Table Operations to support in the OrderedStringListType class
Operation | Description |
Add | Add an element to the list. The element will be added in its proper, sorted position among the other existing elements. |
Clear | Clear the list of all elements. |
Contains | Determine whether a particular value is stored in the list. get Get a value from a specific index. |
indexOf | Get the index of the first occurrence of a specific value in the list. |
isEmpty | Determine whether the list is empty. |
Remove | Remove a specific value, if it exists, from the list. |
Remove | Remove an element at a specific index. |
Size | Get the number of elements stored in the list. |
Note that when the add operation is called, the list class will determine the position of the element. Instead of storing elements in the order that they are added, the class should store elements in ascending order.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.