typedef struct lnode{
Elemtype data;
struct Lnode *next;
}*link,*position; typedef struct{
Link Head,tail;
int Len;
}linklist; Status Makenode (Link &p,elemtype e); Assign a node with a value of e that is pointed to by P and return OK if the allocation fails void Freenode (Link &p); Release P-point node Status initlinst (linklist &l); Construct an empty linear linked list L Status destroylinst (linklist &l); Destroy linear list l,l no longer exists Status clearlist (linklist &l); Reset the linear chain table L to an empty table and release the node space of the original list Status Insfirst (Link h,link s); H is known to point to the head node of the linear list, and the node of S is inserted before the first node. Status Delfirst (Link h,link &q); H is known to point to the head node of the linear list, delete the first node in the list and return with Q. Status Append (linklist &l,link s); Link the last node of the linear list L with a string of nodes that the pointer s refers to (each other as a chain of pointers) And then change the tail pointer of the list L to point to the new tail node. Status Remove (linklist &l,link &q); Delete the tail node in the linear list L and return with Q, change the tail pointer of the list L to point to the new tail node Status Insbefore (linklist &l,link &p,link s); It is known that p points to a node in the linear chain table L and that the node of S is inserted before the node indicated by P. and modify the pointer p to point to the newly inserted node Status insafter (linklist &l,link &p,link s); It is known that p points to a node in the linear chain table L, and that the node of S is inserted after the point of P. and modify the pointer p to point to the newly inserted node Status Setcurelem (Link &p,elemtype e); P is known to point to a node in a linear list, and the value of the data element in the node of P is updated with E. Elemtype Getcurelem (Link p); It is known that p points to a node in a linear list and returns the value of the data element in the node that P refers to Status listempty (linklist L); Returns true if the linear list L is an empty table, otherwise returns false int Listlength (linklist L); Returns the number of elements in a linear list L Position GetHead (linklist L); Returns the position of the first node in the linear chain table L Position getlast (linklist L); Returns the position of the last node in the linear list L Position priorpos (linklist l,link p); It is known that p points to a node in the linear chain table L and returns the direct forward value of the node referred to P If not, return null Position nextpos (linklist l,link p); It is known that p points to a node in the linear chain table L and returns the direct subsequent value of the node referred to P If no successor, return NULL Status Locatepos (linklist l,int i,link &p); Returns the error when p indicates the position of the first node in the linear list L and returns the Ok,i value when it is not valid. Position Locateelem (linklist l,elemtype E, Status (*compare) (Elemtype,elemtype)); Returns the position of the 1th element in the linear list l that satisfies the compare () decision of the function. If such an element exists, NULL is returned Status Listtraverse (linklist l,status (*visit)); Call function visit () for each element of L in turn. Once visit () fails, the operation fails. |