#include #include"simpleList.hpp" using namespace std; bool simpleList::isEmpty() { return head==nullptr; } simpleList::~simpleList(){ simpleNode *tmp; while(!isEmpty()) { tmp=head; head=head->next; delete tmp->item; delete tmp; } } simpleList *simpleList::HInsert(simpleItem *i) { simpleNode *newNode; newNode=new simpleNode(i); if(isEmpty()) head=tail=newNode; else { newNode->next=head; head=newNode; } return this; } simpleItem *simpleList::HRemove() { simpleNode *tmp; simpleItem *i; if (isEmpty()) return nullptr; tmp=head; i=head->item; if (head==tail) head=tail=nullptr; else head=tmp->next; delete tmp; return i; } simpleList *simpleList::TInsert(simpleItem *i) { simpleNode *newNode; newNode=new simpleNode(i); if(isEmpty()) tail=head=newNode; else { tail->next=newNode; tail=newNode; } return this; } simpleItem *simpleList::TRemove() { simpleNode *tmp,*curr; simpleItem *i; if(isEmpty()) return nullptr; tmp=tail; curr=head; if(head==tail) tail=head=nullptr; else { while(curr->next!=tmp) curr=curr->next; curr->next=nullptr; tail=curr; } i=tmp->item; delete tmp; return i; }