标签:链表
1、 链表定义
typedef struct ListElement_t_ {
void *data;
struct ListElement_t_ *next;
} ListElement_t;
typedef struct List_t_{
int size;
int capacity;
ListElement_t *head;
ListElement_t *tail;
} List_t;2、给定链表中间某个节点,将待插入节点插入给定节点之前
先将待插入节点插入给定节点之后,然后交换这两个节点数据,就相当于将带插入节点插入给定节点之前
int InsertNode( ListElement_t *GNode, ListElement_t *TNode){
if( GNode == NULL || TNode == NULL )
return ERROR;
TNode->next = GNode->next;
GNode->next = TNode;
void *tmp = GNode->data;
GNode->data = TNode->data;
TNode->data = tmp;
return 0;
}
链表(15)----给定链表中间某个节点,将待插入节点插入给定节点之前
标签:链表
原文地址:http://blog.csdn.net/beitiandijun/article/details/41916053