1、头文件c_doublelist.h
#include
typedef struct Node
{
struct Node* next;
struct Node* prior;
}Node;
typedef struct DoubleNode
{
Node node;
void* data;
}DoubleNode;
typedef struct DoubleList
{
DoubleNode header;
int length;
}DoubleList;
void InitList(DoubleList*);
int ListEmpty(DoubleList*);
int ListLength(DoubleList*);
void ListInsert(DoubleList*, int, void*);
void PrintList(DoubleList*);
void PrintList_Reverse(DoubleList*);
void CreateList(DoubleList*, int);
void ListDelete(DoubleList*, int, void**);
void GetElem(DoubleList*, int, void**);
void ClearList(DoubleList*);
void DestroyList(DoubleList*);
2、相关操作函数实现文件c_doublelist.c
#include
#include
#include
#include "c_doublelist.h"
void InitList(DoubleList* L)
{
L->header.node.next = NULL;
L->header.node.prior = NULL;
L->length = 0;
}
int ListEmpty(DoubleList* L)
{
if(L->length == 0)
return 1;
else
return 0;
}
int ListLength(DoubleList* L)
{
return L->length;
}
void ListInsert(DoubleList* L, int pos, void* e)