一个双向链表程序(单进程)

houjiuming 52 0 ZIP 2019-04-07 10:04:14

/** * db_list.h : public header for application */ #ifndef DB_LIST_H #define DB_LIST_H #include /** * Basic structures */ typedef void info_t; typedef struct node { info_t *info; struct node *next; struct node *prev; } node_t; typedef struct list { node_t *head; node_t *tail; node_t *current; size_t info_size; unsigned long current_index; unsigned long list_size; } list_t; /** * Prototypes */ /* List initialization routines */ list_t *list_create(list_t ** list); int list_init(list_t * list, size_t info_size); void list_destroy(list_t ** list); /* Status and state routines */ int list_empty(list_t * list); unsigned long get_list_size(list_t * list); /* List update routines */ int list_add(list_t * list, info_t * info); int list_add_tail(list_t * list, info_t * info); int list_replace(list_t * list, node_t * new_node); int list_del(list_t * list); int list_clear(list_t * list); int list_move(list_t * list, list_t * list_a); int list_move_tail(list_t * list, list_t * list_a); /* List search routines */ int find_record(list_t * list, info_t * match, int (*cmp) (info_t *, info_t *)); info_t *get_current_record(list_t * list); info_t *get_next_record(list_t * list); info_t *get_prev_record(list_t * list); info_t *get_first_record(list_t * list); info_t *get_last_record(list_t * list); /* Input/Output routines */ int export_list(list_t * list, const char *path); int import_list(list_t * list, const char *path); #endif /* DB_LIST_H */ *current; size_t info_size; unsigned long current_index; unsigned long list_size; } list_t; /** * Prototypes */ /* List initialization routines */ list_t *list_create(list_t ** list); int list_init(list_t * list, size_t info_size); void list_destroy(list_t ** list); /* Status and state routines */ int list_empty(list_t * list); unsigned long get_list_size(list_t * list); /* List update routines */ int list_add(list_t * list, info_t * info); int list_add_tail(list_t * list, info_t * info); int list_replace(list_t * list, node_t * new_node); int list_del(list_t * list); int list_clear(list_t * list); int list_move(list_t * list, list_t * list_a); int list_move_tail(list_t * list, list_t * list_a); /* List search routines */ int find_record(list_t * list, info_t * match, int (*cmp) (info_t *, info_t *)); info_t *get_current_record(list_t * list); info_t *get_next_record(list_t * list); info_t *get_prev_record(list_t * list); info_t *get_first_record(list_t * list); info_t *get_last_record(list_t * list); /* Input/Output routines */ int export_list(list_t * list, const char *path); int import_list(list_t * list, const char *path); #endif /* DB_LIST_H */

用户评论
请输入评论内容
评分:
暂无评论