#include "List.h" template class SortedList : public List // ASSUMPTIONS ON type T: // 1) elements of type T can be compared with operators < and == // 2) T should not be int, otherwise items get mixed with indexes!!! // NOTE: in c++ there is no tool how to specify such requirements // on s template parameter { public: // SortedList() {} // if you need your constructor to initialized some added data members // uncomment the constructor and provide a code for it. // Note: it will automatically call the default constructor of List class. // The following methods are inherited from the class List. // If you need to override any of them, uncommnent it and provide // a new code for the method. // bool isEmpty() const; // Determines whether a list is empty. // Postcondition: Returns true if the list is empty, otherwise returns false. // int size() const; // Determines the length of a list. // Postcondition: Returns the number of items that are currently in the list. // void removeAll(); // Deletes all the items from the list. // Postcondition: The list is empty. // void add(int i, const T& item) // throw(ListIndexOutOfRangeException, 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: ListIndexOutOfRangeException if index < 1 or // index > size()+1. // Throws: ListException if item cannot be placed on // the list. // const T& get(int i) const // throw(ListIndexOutOfRangeException); // Precondition: 1 <= i <= size() // Postcondition: The i-th smallest item in the list is returned. // Throws: ListIndexOutOfRangeException if index < 1 or // index > size(). // void remove(int i) // throw(ListIndexOutOfRangeException); // Precondition: 1 <= i <= size() // Postcondition: The i-th smallest item in the list is removed // from the list. // Throws: ListIndexOutOfRangeException if index < 1 or // index > size(). // The following are the new methods of the class: void remove(const T& item); // Precondition: none // Postcondition: All occurrences of ‘item’ are removed from the list. int count(const T& item) const; // Precondition: none // Postcondition: Returns the number of occurrences of ‘item’ // in the list. }; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Provide definitions of overridden methods and two new methods here: