public interface SortedListInterface extends ListInterface { // The following methods are inherited from the ListInterface. // Since they are inherited, they do not need to be redefine here, // but since they might have different meaning in SortedList, we provide // their specification here. // public boolean isEmpty(); // Determines whether a list is empty. // Postcondition: Returns true if the list is empty, otherwise returns false. // public int size(); // Determines the length of a list. // Postcondition: Returns the number of items that are currently in the list. // public void removeAll(); // Deletes all the items from the list. // Postcondition: The list is empty. // public void add(int i, T item) // throws ListIndexOutOfBoundsException, ListException; // Precondition: 1 <= i <= size()+1 and there is enough space // in the list for a new item. // Postcondition: The size of the list is incremented by 1 and the // the number of elements ‘item’ has increased by 1. The position i // is a recommended position where to start looking for position // where to insert ‘item’. It can be ignored. // Throws: ListIndexOutOfBoundsException if index < 1 or // index > size()+1. // Throws: ListException if item cannot be placed on // the list. // public T get(int i) // throws ListIndexOutOfBoundsException; // Precondition: 1 <= i <= size() // Postcondition: The i-th smallest item in the list is returned. // Throws: ListIndexOutOfBoundsException if index < 1 or // index > size(). // public void remove(int i) // throws ListIndexOutOfBoundsException; // Precondition: 1 <= i <= size() // Postcondition: The i-th smallest item in the list is removed // from the list. // Throws: ListIndexOutOfBoundsException if index < 1 or // index > size(). // The following are the new methods of the interface: public void remove(T item); // Precondition: none // Postcondition: All occurrences of ‘item’ are removed from the list. public int count(T item); // Precondition: none // Postcondition: Returns the number of occurrences of ‘item’ // in the list. }