///
///
// Link table data structure list.h //
///
//
#include
Template
Class List;
Template
Class ListNode
{
PUBLIC:
Friend Class List
Private:
TYPE DATA;
ListNode
}
Template
Class List
{
PUBLIC:
List ();
~ List ();
Void Insert (Type); / / Insert an element to the tail of the linked list
BOOL INSERT (Type, int); / / Insert an element in any position to the linked list
Void Delnode (INT i); // Delete Elements
INT FIND (Type T); // Find elements
void makeempty (); // destroyed list
Bool print (); // Printing list
INT getlen (); // Get the length of the linked list
Private:
ListNode
Int length;
}
Template
Void InitList (Type & TMP);
Template
Void List_Exit (List
Void initation ();
Template
Void List_inSertend (List
Template
{
Return Length;
}
Template
{
ListNode
P1 = first-> next;
First-> next = NULL;
While (p1! = null)
{
P2 = P1;
P1 = p1-> next;
Delete P2;
}
Length = 0;
}
Template
{
ListNode
P = new listNode
P-> DATA = T;
P-> Next = NULL;
Last-> next = p;
Last = P;
Length ;
}
Template
{
ListNode
p = first;
INT K = 1;
While (p! = NULL && K
{
P = P-> next;
K ;
}
IF (p == NULL && K! = i)
Return False;
Else
{
ListNode
TP = New ListNode
TP-> DATA = T;
TP-> next = p-> next; p-> next = TP;
Length ;
Return True;
}
}
Template
{
INT k = 1;
ListNode
p = first;
While (P-> Next! = NULL && K! = i)
{
P = P-> next;
K ;
}
T = p-> next;
Cout << "You have already deleted the data item << t-> data <<" "delete" << ENDL;
P-> Next = P-> Next-> next;
Length -;
Delete T;
}
Template
{
ListNode
IF (Length == 0)
Return False;
Else
{
There is "<< length <<" item data in the COUT << "Link:" << ENDL;
While (p)
{
Cout << P-> Data << "
P = P-> next;
}
}
Cout << Endl;
Return True;
}
Template
{
ListNode
INT i = 1;
While (P && P-> Data! = T)
{
P = P-> next;
i ;
}
IF (p)
Return I;
Else
Return 0;
}
Template
{
DELETE FIRST;
Cout << "Welcome to use (! ^!)" << Endl;
}
Template
{
ListNode
Node-> next = NULL;
First = last = node;
Length = 0;
}