-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathllist.h
52 lines (38 loc) · 911 Bytes
/
llist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _LLIST_H_
#define _LLIST_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int i;
int j;
void* k;
}ELE;
struct lnode{
struct lnode *prev, *next;
ELE* element;
};
//包含整个链表元素个数和头结点
typedef struct{
struct lnode head;
int num;
}LLIST;
//函数指针,为了查找元素,key是要查找元素的关键字
typedef int(*list_find_p)(ELE* pELE, void *key);
typedef void(*list_travel_p)(ELE* pELE, void *key);
LLIST* lhandle;
list_travel_p travel_p;
list_find_p find_p;
LLIST* llist_creat(void);
//后插,插在链表的最后
int llist_append(LLIST* handle, ELE* pnode);
//前插,插在头结点的后面的第一个结点
int llist_preappend(LLIST* handle, ELE* pnode);
int llist_size(LLIST* handle);
void llist_destory(LLIST* handle);
int llist_delete(LLIST* handle, list_find_p find, void* key);
void llist_travel(LLIST* handle, list_travel_p trav, void* arg);
#ifdef __cplusplus
}
#endif
#endif //llist.h