#include <stdio.h>
#include <lstLib.h>
typedef struct _Queue
{
NODE * next;
NODE * prev;
int age;
char name[255];
} QUEUE;
LIST list;
void TestList()
{
QUEUE *p;
int i;
lstLibInit();
lstInit(&list);
for(i = 0; i < 10; i++)
{
p = malloc(sizeof(QUEUE));
if(p)
{
p->age = i * 5;
sprintf(p->name, "person %d", i);
lstAdd(&list, (NODE*)p);
}
}
for(i = 0; i < 10; i++)
{
p = (QUEUE*)lstGet(&list); //执行该语句后,该节点会自动被删除
if(p)
{
printf("name = %s, age = %d\n", p->name, p->age);
free(p);
}
}
lstFree(&list);
}
lstLibInit( ) - initializes lstLib module
lstInit( ) - initialize a list descriptor
lstAdd( ) - add a node to the end of a list
lstConcat( ) - concatenate two lists
lstCount( ) - report the number of nodes in a list
lstDelete( ) - delete a specified node from a list
lstExtract( ) - extract a sublist from a list
lstFirst( ) - find first node in list
lstGet( ) - delete and return the first node from a list
lstInsert( ) - insert a node in a list after a specified node
lstLast( ) - find the last node in a list
lstNext( ) - find the next node in a list
lstNth( ) - find the Nth node in a list
lstPrevious( ) - find the previous node in a list
lstNStep( ) - find a list node nStep steps away from a specified node
lstFind( ) - find a node in a list
lstFree( ) - free up a list