#include #include "SListT.h" #include using namespace std; struct NodeT { ItemT data; NodeT * next; }; ListT::~ListT() { NodeT * tmp {head}; while (tmp != nullptr) { tmp = tmp ->next; delete head; head = tmp; } } void ListT::PushFront(ItemT newData) { NodeT * tmp{new NodeT{newData, head}}; ++size; head = tmp; if (nullptr == tail) { tail = head; } } void ListT::PopFront() { if (nullptr == head) { throw out_of_range{"Attempt to delete an empty list in SListT"}; } else { NodeT * tmp{head}; head = head->next; delete tmp; --size; if (nullptr == head) { tail = nullptr; } } } size_t ListT::Size() const { return size; } void ListT::Home() { ptr = head; } bool ListT::Next() { if (nullptr == ptr) { return false; } else { ptr = ptr->next; return true; } } bool ListT::AtEnd() { return ptr == nullptr; } ItemT & ListT::Data() { if (nullptr != ptr) { return ptr->data; } else { throw out_of_range{"Attempt to dereference null pointer in SListT"}; } }