| 30 | Truckload::Iterator findSmallestBox(const Truckload& truckload); |
| 31 | |
| 32 | int main() |
| 33 | { |
| 34 | Truckload load; // Create an empty list |
| 35 | |
| 36 | // Add 12 random Box objects to the list |
| 37 | const size_t boxCount{ 12 }; |
| 38 | for (size_t i{}; i < boxCount; ++i) |
| 39 | load.addBox(randomSharedBox()); |
| 40 | |
| 41 | std::cout << "The random truckload:\n"; |
| 42 | load.listBoxes(); |
| 43 | std::cout << std::endl; |
| 44 | |
| 45 | const auto largestIter{ findLargestBox(load) }; |
| 46 | const auto smallestIter{ findSmallestBox(load) }; |
| 47 | |
| 48 | std::cout << "The largest box (found using forward iteration) is "; |
| 49 | largestIter.getCurrentBox()->listBox(); |
| 50 | std::cout << '\n' << std::endl; |
| 51 | |
| 52 | load.removeBox(largestIter); |
| 53 | |
| 54 | std::cout << "The truckload without its largest box:\n"; |
| 55 | load.listBoxes(); |
| 56 | std::cout << std::endl; |
| 57 | |
| 58 | std::cout << "The smallest box (found using reverse iteration) is "; |
| 59 | smallestIter.getCurrentBox()->listBox(); |
| 60 | std::cout << '\n' << std::endl; |
| 61 | |
| 62 | load.removeBox(smallestIter); |
| 63 | |
| 64 | std::cout << "The truckload without its smallest box (in reverse order):\n"; |
| 65 | load.listBoxesReversed(); |
| 66 | } |
| 67 | |
| 68 | Truckload::Iterator findLargestBox(const Truckload& truckload) |
| 69 | { |
nothing calls this directly
no test coverage detected