c++データ構造のループチェーンテーブル


c++テンプレートクラスループチェーンテーブル
#include
#include
using namespace std;
template<class T> class List;//    

template<class T>
class ListNode{
    friend class List<T>;
    private:
    ListNode<T> *link;
    T data;
    ListNode(T);
    ListNode(){}
};
template<class T>
ListNode<T>::ListNode(T element){
    data=element;
    link=0;
}
template<class T>
class List{
    public:
    List(){first = new ListNode <T>;first->link=first;};
    void Insert(T);
    void Delete(T);
    // void Invert();
    // void show();
    // void Concatentate(List);
    private:
    ListNode<T> *first;
};
template<class T>
void List<T>::Insert(T k){
    ListNode<T> *newnode=new ListNode<T> (k);
   newnode->link = first->link;//newnode->link = first;
	first->link = newnode;//first = newnode;
}
template<class T>
void List<T>::Delete(T k){
ListNode<T> *previous=first;
ListNode<T> *current;
for (current = first->link;
		(current!=first)&&current->data != k;
		previous = current, current = current->link)
	{
		;
	}
	if (current!=first)
    previous->link = current->link;
			delete current;
}
// template
/* void List::Invert(){
    ListNode *p=first,*q=0;
    while(p)
    {
        ListNode *r=q;q=p;
        p=p->link;
        q->link=r;
    }
    first=q;
}
template
void List::show(){
for(ListNode *current=first;current;current= current->link){
    std::cout<data;
    if(current->link) std::cout<";
}
std::cout<<:endl template="" t="">
void List::Concatentate(List b)
{
	if (!first){first = b.first; return;}
	if (b.first)
    {
			ListNode *p;
			for (p = first; p->link; p = p->link) ;//   
			p->link = b.first;
	}
}
 */
int main(){
    
    List <int> intlist;
    intlist.Insert(5);
    intlist.Insert(15);
    intlist.Insert(25);
    intlist.Delete(5);

    return 0; 
}