1)Define the ‘<’ and ‘>’ operators for the SmallPacket and LargePacket classes from assignment 1. SmallPackets should be ordered based on the ‘value,’ and LargePackets based on the ‘height.’ 2)Implement a template List class, using a dynamically allocated array, as discussed in the lecture. The initial size of the array should be passed as an argument to the constructor. The class should be tested with values of type ‘int’, then of type of ‘SmallPacket,’ then of type ‘LargePacket.’ The class should contain the following member functions: Constructor Takes a single int argument used to specify the initial size of the storage. If the size is not passed as an argument, the initial size of the storage should be 20. Destructor Ensures that there are no memory leaks. void display() const Displays all values currently stored in the list. void displayReverse() const Displays all values currently stored in the list, in reverse order. void insertFront(const T& num) Takes a single argument representing the value to be inserted into the front of the list. If the list is already full, the size of the storage should be doubled and the new value inserted. All previously inserted values should be retained in the same order. void insertEnd(const T& num) Takes a single argument representing the value to be inserted at the end of the list. If the list is already full, the size of the storage should be doubled and the new value inserted. All previously inserted values should be retained in the same order. void insertInOrder(const T& num) Takes a single argument representing the value to be inserted into the list. Following this insertion, values should be stored in the list in ascending order. If the list is already full, the size of the storage should be doubled and the new value inserted. All previously inserted values should be retained in the same order. If this function is called on a list, do not call either of the other insert functions on the same list int getSize() const Returns the current size of the list. int getNumValues() const Returns the current number of values stored in the list. T getValue(int index) const Returns the value at the specified index in the list. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|