This is a header file
/ ************************************************** ****************** This library consists of two files of list.h and list.c: list. Handle, which contains supplied to users, node Handle also has a GET macro that is convenient, and the declaration of the external interface is a list of data structures defined by the linked list. The definition of the external interface: This library is a generic two-way linked list, consider To the efficiency, when adding or deleting data on the head or tail, if you use Pushback, Popback, Pushfront, PoPFront, the speed depends only on the time execution of the function call. If it is a random insert or delete node, Since I define a listiterator function in the interface, this function first judges the node position to operate. If it is close to the position of the header, then from the header operation, if the position from the tail is closer, then. Therefore, the number of iterations should be Length / 2. For abnormal processing, it uses assert. This library compiles in DEV-C 4.9.9.0 - Avalon QQ: 1243128 01/104 18:27 **** *********************************************************** ************** / # ifndef list_h # deflude
#ifndef list_bool # define list_bool # Define true 1 # define false 0typedef int bool; #ENDIF
Typedef struct lnode lnode, * nodehandle; typedef struct list list, * listhandle;
#define get (* ((DataType *))) / * This macro is to facilitate user use, because this library provides to the user's interface can only be a pure pointer. DataType : Represents data types, such as int, long, double voidpoint:, represents the address, in this general (void *), such as original: Printf ("% d", * ((int *) begin (la))); The macro can be written: Printf ("% D", Get (INT, Begin (LA))); * /
NodeHandle Makenotes (ListHandle L, Void * Data); / * Take the contents of the contents of the data to the newly assigned space and return to the address of the new allocation space * / void freenode (nodehandle * n); / * Release N Node space * /
NodeHandle ListIterator (ListHandle L, INDEX); / * Returns a pointer pointing to node based on the value of index index * /
Void * getof (ListHandle L, INDEX); / * Returns the pointer of DATA data in the node referred to index index * /
ListHandle InitList (size_t type); / * Constructs a hollow table TYPE indicates that the value passed through sizeof () * /
INT LISTLENGTH (ListHandle L); / * Returns the length of the table L * / void * begin (ListHandle L); / * Returns the pointer of the table head * / void * end (listhandle L); / * Return the tail tail Pointer * / BOOL LISTEMPTY (ListHandle L); / * Table L Whether it is empty * / Bool Pushback (ListHandle L, Void * DATA); / * In the tail screwing node, its data is data referred to DATA * * / BOOL PUSHFRONT (ListHandle L, Void * Data); / * Insert a node in the table, its data is data referred to in Data * / Bool InsertNode (ListHandle L, INDEX, VOID * DATA); / * In an index Insert a node before position, its value is the content of Void * * /
Void * Popback (ListHandle L); / * Popping a node from the tetheld and returns the address of this sought value, such as NULL returns, is indicated as empty table * / void * PopFront (ListHandle L); / * From the table first pop up a node and return the address of this node value, such as returning NULL, is indicated as empty list * / bool deletenode (ListHandle L, int index); / * Delete the index position Point * / void clearList (ListHandle L); / * Clear Link Lab L * / Void DestoryList (ListHandle * L); / * Destruction Lin Lum L * /
#ENDIF