C language chain table implementation (modified version) header file

xiaoxiao2021-04-03  209

/Linklist.h/////

// Several semaphore 1 # define false 0 # define ok 1 # Define error 0 # define overflow 'o' # define outb -2 // Crossing error

// Status Return Value Type Definition TYPEDEF INT Status;

// Link table storage element type typefedef struct {int element;} elemType; // Link table node type definition TypeDef struct lnode {elemType Data; struct lnode * next;} * link, * position; // Link list definition (substantially only linked list Head) Typedef struct {link head, tail; int Len;} linklist;

/ / =========================================================================================================================================================================================== ==================================================== // Function declaration list // ============================================================================================================================================================================================================= =================================================== // Assign a P pointing value E The node and returns OK; if the assignment fails, ErrorStatus Makenode (Link & P, ElemType E);

/ / Release P Points Nodes Void Freenode (Link & P);

// Initialize a declared list LSTATUS INITLIST (Linklist & l);

// Destroy a linked list LSTATUS DESTROYLIST (Linklist & L);

// Clear the current linked list, turn into an initial status Link table Status ClearList (Linklist & L);

/ / Insert a new node in the head node position, h points to the head, and s point to the new node Status Insfirst (Linklist & H, Link S);

// Remove the head node to STATUS DELFIRST (Linklist & H, Link & Q); // Insert data into the list, one or several nodes after s, and modify the tail pointer of the linked list Status Append (Linklist & L, LINK S);

/ / Remove the chain tail node element, return to Status Remove (Linklist & L, Link & Q) by Q;

// Insert the element into the previous position of the location of the P designated position, and modify P pointing to the new node Status Insbefore (Linklist & l, Link & P, Link S);

// Insert the element into the next position of the P designated position, and modify P to point to the new node Status Insfter (Linklist & L, Link & P, Link S);

/ / Modify the value of the data domain of the element pointing to the current pointer P to Estatus Setcurelm (Link & P, ElemType E);

/ / Get the value of the data field of the element pointing to the current pointer P, returns Status getcurelm (Link & P, ElemType & E) in E;

// Gudge whether the current linked list is empty, returns the result in True and False (Linklist L);

// Return to the location of the header node position GetHead (Linklist L);

// Return the position of the last node in the list Position GetLast (Linklist L);

// The position Position PriorPos (Linklist L, Link P) of the neighboring front of P is found by the current P position.

// Point from the current P, lookup POSITION NEXTPOS (Linklist L, LINK P) of the next neighboring element of P;

/ / Get the position of the i-th element in the current list, if i does not exist, ErrorStatus LocatePos (Linklist L, Link & P, Int i);

/ / Look for the position of the first element of the current linked list, not to find the ErrorPosition Locateelem (Linklist L, ELMTYPE E);

// Traverse the entire list, return FalshStatus ListTraverse if traversal fails;

// All functions declaration

转载请注明原文地址:https://www.9cbs.com/read-131623.html

New Post(0)