Because there is a routine to use the linked list, simply write a linked list, the pure Chain List is actually written very little. Once written, it feels very beneficial.
/* Sort _list.h -- linked list header file */</P> <p>/* data type definition */</P> <p> typedef int sort _list_item; <br/> typedef struct pai_list_node <br/>{< br/> pai_list_item V; <br/> pai_list_item W; <br/> struct pai_list_node * next; <br/>} pai_list_node; <br/> typedef pai_list_node * List; </P> <p>/* interface function declaration */</P> <p>/* operation: Before initializing a linked list */<br/>/* operation: after PLI points to a linked list */<br/>/* operation: Initialize the linked list to be empty and return 1 */<br/>/* time complexity: O (1) */<br/> int initialize_l (list * const PLI); </P> <p>/* operation: determine whether the linked list is empty */<br/>/* before the operation: PLI points to an initialized linked list */<br/>/* after the operation: If the linked list is empty, 1 is returned; otherwise 0 */<br/>/* time complexity: O (1) */<br/> int isempty_l (const list * const PLI ); </P> <p>/* operation: add an element to the linked list */<br/>/* before the operation: PLI points to an initialized linked list, Li1, li2 is the data of the elements to be added */<br/>/*: if the memory allocation is successful, 1 is returned when the data fields Li1 and li2 are added to the head of the linked list; otherwise, 0 */<br/>/* time complexity is returned: O (1) */<br/> int insert_l (list * const PLI, const pai_list_item Li1, const pai_list_item li2); </P> <p>/* operation: Find the data field in the linked list as the specified data element */<br/>/* before the operation: PLI points to an initialized linked list. Li1 and li2 are the specified data to be searched */<br/>/*. If this element is found, 1 is returned; otherwise, 0 */<br/>/* time complexity is returned: O (n) */<br/> int find_l (const list * const PLI, const pai_list_item Li1, const pai_list_item li2); </P> <p>/* operation: before deleting an element whose data field in the linked list is the specified data */<br/>/* operation: PLI points to an initialized linked list. Li1 and li2 are the specified data to be deleted */<br/>/*: If this element is found, 1 is returned; otherwise, 0 */<br/>/* time complexity is returned: O (n) */<br/> int delete_l (list * const PLI, const pai_list_item Li1, const pai_list_item li2); </P> <p>/* operation: one function acts on all elements in the linked list one time from start to end */<br/>/* before the operation: PLI points to an initialized linked list, And pfun points to a function that does not return a value. After receiving a function */<br/>/* to which the pointer type parameter is directed: the function pointed by fun acts on all elements in the linked list one time from start to end */<br/>/* time complexity: O (N) */<br/> void traversal_l (const list * const PLI, void (* pfun) (const pai_list_node * const PLN); </P> <p>/* operation: release the memory space occupied by a linked list */<br/>/* before the operation: PLI points to an initialized linked list */<br/>/* after the operation: the memory space occupied by the linked list is released */<br/>/* time complexity: O (n) */<br/> void release_l (const list * const PLI );