diff --git a/assignment3/as3/main.cpp b/assignment3/as3/main.cpp index 7f5bc95..a0d30a8 100644 --- a/assignment3/as3/main.cpp +++ b/assignment3/as3/main.cpp @@ -12,6 +12,8 @@ namespace ads { /** * @brief The Queue class + * + * implemented with linked list. */ template class Queue @@ -50,11 +52,24 @@ public: return !head_ and !tail_ ; } + ~Queue() + { + do_destructor(); + } + private: Node* head_{nullptr}; Node* tail_{nullptr}; SizeType size_{0}; + void do_destructor() + { + if(! empty()) + for(Node* curr = head_ , *temp; (temp=curr); delete temp) + curr = curr->next_; + head_ = tail_ = nullptr; + } + void do_join(T&& t) { if(empty()) @@ -88,7 +103,7 @@ private: /** * @brief The FileReader class * - * RAII for ifstream + * generator based on ifstream */ class FileReader { @@ -118,6 +133,8 @@ private: /** * @brief The Pool struct + * + * i.e. vector of queues */ template struct Pool : public std::vector >