ZE-Standard-Libraries/list/list.h

122 lines
4.1 KiB
C
Raw Normal View History

2018-07-23 04:59:16 +00:00
#ifndef LIST_H
#define LIST_H
#include "../type/type.h"
2018-07-25 14:10:09 +00:00
#include "../id/id.h"
2018-07-23 04:59:16 +00:00
2018-08-17 08:58:15 +00:00
#define lni(x) nodeWithInt(x,0)
#define lnd(x) nodeWithDouble(x,0)
#define lns(x) nodeWithString(x,0)
#define lnp(x) nodeWithPointer(x,0)
#define lsni(x) nodeWithInt(x,1)
#define lsnd(x) nodeWithDouble(x,1)
#define lsns(x) nodeWithString(x,1)
#define lsnp(x) nodeWithPointer(x,1)
#define lisrti(list, x) insertInTail(list, lni(x));
#define lisrtd(list, x) insertInTail(list, lnd(x));
#define lisrtp(list, x) insertInTail(list, lnp(x));
#define lisrts(list, x) insertInTail(list, lns(x));
#define lidxp(list, x) getByPointerForNode(findByIndexForNode(list, x))
#define lidxi(list, x) getByIntForNode(findByIndexForNode(list, x))
#define lidxd(list, x) getByDoubleForNode(findByIndexForNode(list, x))
#define lidxs(list, x) getByStringForNode(findByIndexForNode(list, x))
2018-08-03 03:38:19 +00:00
int safeModeForNode(int ifon);
int releaseSingleListForsafeModeForNode(List *p_list);
int releaseSingleNodeForsafeModeForNode(List *p_list);
int releaseAllForNode(void);
2018-07-23 04:59:16 +00:00
2018-08-14 15:59:55 +00:00
List *initList(_Bool if_sid);
Node *initNode(_Bool if_sid);
s_Node *s_initNode(void);
2018-07-23 04:59:16 +00:00
2018-08-07 04:10:55 +00:00
int initMallocValueForNode(Node *,unsigned int,const void *);
2018-07-23 04:59:16 +00:00
int insertInHead(List *p_list, Node *p_node);
int insertInTail(List *p_list, Node *p_node);
2018-08-17 08:58:15 +00:00
int insertAfterNode(List *p_list, Node *t_node, Node *p_node);
int insertBeforeNode(List *p_list, Node*t_node, Node *p_node);
2018-08-14 15:59:55 +00:00
int s_insertInHead(List *p_list, s_Node *s_p_node);
int s_insertInTail(List *p_list, s_Node *s_p_node);
2018-07-23 04:59:16 +00:00
2018-08-14 15:59:55 +00:00
int replaceNode(List *p_list, Node *pt_node, Node *p_node);
2018-08-17 08:58:15 +00:00
int exchangeNode(List *p_list, Node *f_node, Node *s_node);
2018-07-23 04:59:16 +00:00
Node *copyNode(Node *);
2018-08-17 08:58:15 +00:00
int removeById(List *p_list, SID *s_id);
2018-07-23 04:59:16 +00:00
int removeByNode(List *p_list, Node *p_node);
int popFromHead(List *p_list);
int popFromTail(List *p_list);
2018-08-03 03:38:19 +00:00
unsigned long long len(List *p_list);
2018-07-23 04:59:16 +00:00
2018-08-17 08:58:15 +00:00
Node *findByIdForNode(List *p_list, SID * s_id);
2018-08-03 03:38:19 +00:00
Node *findByValue(List *p_list, unsigned int type, const void *value);
List *mply_findByValue(List *p_list, unsigned int type, const void *value);
2018-07-23 04:59:16 +00:00
2018-08-03 03:38:19 +00:00
int releaseList(List *p_list);
2018-08-14 15:59:55 +00:00
int s_releaseList(List *p_list);
2018-08-03 10:32:20 +00:00
int releaseListForCustom(List *p_list, int (*func)(void *));
2018-08-14 15:59:55 +00:00
int s_releaseListForCustom(List *p_list, int (*func)(void *));
2018-08-03 03:38:19 +00:00
int releaseListForSingle(List *p_list);
2018-08-14 15:59:55 +00:00
2018-08-03 03:38:19 +00:00
int releaseNode(Node *p_node);
2018-08-14 15:59:55 +00:00
int s_releaseNode(s_Node *s_p_node);
2018-08-03 10:32:20 +00:00
int releaseNodeForCustom(Node *p_node, int (*func)(void *));
2018-08-14 15:59:55 +00:00
int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *));
2018-08-03 03:38:19 +00:00
int releaseOnlyNode(Node *p_node);
2018-07-23 04:59:16 +00:00
2018-08-03 03:38:19 +00:00
int isListEmpty(List *p_list);
List *copyList(List *p_list);
2018-07-23 04:59:16 +00:00
2018-08-03 10:32:20 +00:00
int pushInfo(Info *p_info, const char *head,const char *body);
Error *pushError(unsigned int type, int pri, Info *p_info);
Notice *pushNotice(unsigned int type, Info *p_info);
Info *initInfo(const char *head, const char *body);
Error *createError(Info *info,unsigned int type,int pri);
Notice *createWarning(Info *info, unsigned int type, int pri);
int showError(Error *);
int showWarning(Notice *);
2018-08-14 15:59:55 +00:00
int enableListQuick(List *p_list);
2018-08-17 08:58:15 +00:00
int refreshFnNode(List *p_list);
int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node));
int sortListByCustom(List *p_list, int(*func)(Node *f_node, Node *s_node));
int indexTransfromer(List *p_list, unsigned long long m_index);
int indexChange(List *p_list, unsigned long long c_index, int move);
Node *getNodeByFnNode(List *p_list, unsigned long long index);
Node *findFnNode(List *p_list, Node *p_node);
void initIdxcList(List *p_list);
void digHole(List *p_list, Node *p_node);
int disableListQuick(List *p_list);
Node *findByIndexForNode(List *, unsigned long long);
Node *findByIntForNode(List *, int);
Node *findByDoubleForNode(List *, double);
Node *findByStringForNode(List *, char *);
Node *findByPointerForNode(List *, void *);
Node *getListTail(List *);
Node *updateNodeByIndex(List *, void *, unsigned long long);
int getByIntForNode(Node *);
unsigned int getByUIntForNode(Node *);
double getByDoubleForNode(Node *);
char *getByStringForNode(Node *);
void *getByPointerForNode(Node *);
unsigned long long getIndexForNode(List *p_list,Node *p_node);
2018-08-14 15:59:55 +00:00
2018-07-23 04:59:16 +00:00
static int if_safeModeForNode;
2018-08-03 03:38:19 +00:00
static List *node_list;
static List *list_list;
2018-07-23 04:59:16 +00:00
#endif