加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
list.h 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
hotmocha 提交于 2015-04-02 22:29 . spider init
#ifndef _LIST_H_
#define _LIST_H_
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#define ARGISNULL -50001
#define NOTFOUND -50002
typedef void (*FreeDataFunc)( void *d );
typedef int (*DataCmpFunc)(void *a, void *b);
typedef int (*TraversalFuncWithData)(void *a, void *b);
typedef int (*TraversalFunc)(void *a);
struct _ListHead {
struct _ListNode *first;
struct _ListNode *last;
struct _ListNode *curr;
int NodeCnt;
} ;
typedef struct _ListHead ListHead;
struct _ListNode {
struct _ListNode *prev;
struct _ListNode *next;
void *data;
/* 这个字段有点多余 */
unsigned long datalen;
};
typedef struct _ListNode ListNode;
ListHead* NewListHead();
ListNode* NewListNode();
void FreeListNode(ListNode *node);
void FreeListNodeAndData(ListNode *node, FreeDataFunc func);
void FreeListHead( ListHead *head );
void* FindDataInList( ListHead *head, void *data, DataCmpFunc func);
void* RFindDataInList( ListHead *head, void *data, DataCmpFunc func);
int InsertDataBeTheFirst( ListHead *head, void *data);
int InsertDataBeTheLast( ListHead *head, void *data);
ListNode* FindNodeInList( ListHead *head, void *data, DataCmpFunc func);
int FindDataAndInsertBefore( ListHead *head, void *data, void *inData, DataCmpFunc func );
int FindDataAndInsertAfter( ListHead *head, void *data, void *inData, DataCmpFunc func );
int DeleteListNodeAndData( ListHead *head, ListNode *node, FreeDataFunc freeFunc );
int DeleteListNode( ListHead *head, ListNode* node);
int FindAndDeleteNodeAndDataAll( ListHead *head, void *data, DataCmpFunc cmp, FreeDataFunc freeFunc);
int FindAndDeleteNodeAll( ListHead *head, void *data, DataCmpFunc cmp);
int FindAndDeleteNodeAndData( ListHead *head, void *data, DataCmpFunc cmp , FreeDataFunc freeFunc);
int FindAndDeleteNode( ListHead *head, void *data, DataCmpFunc cmp );
int TraversalListWithData( ListHead *head, TraversalFuncWithData func, void *data);
int TraversalList( ListHead *head, TraversalFunc func);
/* func必须有值 */
int DamageList( ListHead *head, FreeDataFunc func);
int DamageListNode(ListHead *head, FreeDataFunc freeFunc);
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化