#ifndef _TEMPLLIST_CPP #define _TEMPLLIST_CPP using namespace std; template bool templList::isEmpty() { return head==nullptr; } template templList::~templList(){ templNode *tmp; while(!isEmpty()) { tmp=head; head=head->next; delete tmp; } } template templList *templList::HInsert(itemType i) { templNode *newNode; newNode=new templNode(i); if(isEmpty()) head=tail=newNode; else { newNode->next=head; head=newNode; } return this; } template itemType templList::HRemove() { templNode *tmp; itemType i; if (isEmpty()) return -1; tmp=head; i=head->item; if (head==tail) head=tail=nullptr; else head=tmp->next; delete tmp; return i; } template templList *templList::TInsert(itemType i) { templNode *newNode; newNode=new templNode(i); if(isEmpty()) tail=head=newNode; else { tail->next=newNode; tail=newNode; } return this; } template itemType templList::TRemove() { templNode *tmp,*curr; itemType i; if(isEmpty()) return -1; 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; } #endif